Xaringan slides advance with odd latency in presentation

Viewed 151

I am presenting my slides (same problem in in RStudio as in browser) and the transitions have weird latency. New text comes in, but old text doesn't go away for more than 0.5 sec.

I have a video on YouTube that illustrates the problem.

Not really sure where the problem stems from. Any suggestions?

2 Answers

The issue arises from a mismatch between R's color names and HTML/CSS color names. Here is the source code chunk used in the slides to create the xaringanthemer CSS:

```{r xaringan-themer, include=FALSE, warning=FALSE}
library(xaringanthemer)
style_xaringan(title_slide_background_image = "https://wallpapercave.com/wp/wp2567196.jpg",
               background_color = "grey14",
               title_slide_text_color = "white"
               )
```

Unfortunately "grey14" is an R color, but it's not recognized by HTML, so the slide background becomes transparent. A warning is emitted that hexadecimal colors are expected if used by theme_xaringan(), so I understand why the warning was ignored.

In some cases, the color names are the same — e.g. "white" is both an R and HTML color — so it made sense to me to warn rather than throw an error in cases like these.

You can use col2rgb() to lookup the rgb or hex representation of the color:

col2rgb("grey14")
#>       [,1]
#> red     36
#> green   36
#> blue    36
rgb(36, 36, 36, maxColorValue = 255)
#> [1] "#242424"

So either background_color="#242424" or background_color = "rgb(36,36,36)" would create slides with a solid background.

OK, so I was able to chase down the problem. It is that when you change slides that class temporarily changes from remark-visible to remark-fading which keeps the existing slide active for 1 second. I'm not sure why this particular thing happened (I don't recall it happening when I've made xaringan slides in the past). In any event, you can stop it by putting the following block in your first slide after the background image. Then, everything seemed to work fine for me.

htmltools::tags$style("
.remark-fading{
  display:none
}
")

I also changed it in the RStudio.cloud project and it worked there. I added it right after the background-image() line of the first slide.

Related