如何使项目符号增量显示在RMarkdown的柔性面板情节提要中



我想在单击右箭头时使flexdashboard/情节提要上的项目符号项目递增显示(演示样式(。这是如何实现的?我猜是一个Java脚本,但我不知道从哪里开始。从Rmd导出Ioslides有一个增量项目符号的选项,但我希望能够在每张幻灯片的基础上完成这项工作,而且我喜欢flexdashboard/故事板的更大灵活性。

参见MWE:

---
title: "How to increment?"
output: 
flexdashboard::flex_dashboard:
storyboard: true
---
### Slide 1
```{r}
hist(rnorm(100))
```
***
- I want these bullets
- to appear
- incrementally
### Slide 2
```{r}
hist(runif(100))
```
***
- I want these bullets
- to appear
- all at once
- when this slide
- comes up

对我有效的解决方案是下拉到编织器,并使用该指令进行原始html输出。Rest有点难看。(并不是说javascript是丑陋的。只是我用了丑陋的方式来实现期望的结果。当然还有一种更干净的方式来做同样的事情。(

请注意,这是一个最小的例子——解决方案当前处理整个文档上的onclick事件,而不考虑其他任何事情。因此,如果你决定走这条路,你将不得不处理从第二张幻灯片等返回的情况。

---
title: "How to increment?"
output: 
flexdashboard::flex_dashboard:
storyboard: true
---
### Slide 1
```{r}
hist(rnorm(100))
```

***
```{r}
knitr::raw_html("<ul>")
knitr::raw_html("<li id='test1' style='display:none'> I want these bullets </li>")
knitr::raw_html("<li id='test2' style='display:none'> to appear </li>")
knitr::raw_html("<li id='test3' style='display:none'> incrementally </li>")
knitr::raw_html("</ul>")
```

```{js}
displayed = 0;
display = function() {
displayed++;
id = "test" + displayed;
el = document.getElementById(id);
el.style.display = "list-item";
}
document.onclick=display
```
### Slide 2
```{r}
hist(runif(100))
```
***
- I want these bullets
- to appear
- all at once
- when this slide
- comes up

最新更新