Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (48 sloc) 1.13 KB
---
title: "Callbacks"
author: "John Coene"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Callbacks}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
Callbacks let you pick up on events, i.e.: which slide is currently being viewed. For instance, it comes in handy to display animations at the right moment! Below are the callbacks available to each family of functions:
**fullPage**
- `input$fp_origin`: origin slide
- `input$fp_destination`: destination slide
- `input$fp_direction`: scroll direction
**pagePiling & multiScroll**
- `input$fp_anchor`: slide anchor
- `input$fp_index`: slide index
Demo:
```r
library(shiny)
library(fullPage)
ui <- fullPage(
fullSection(
menu = "first",
center = TRUE,
h1("Callbacks")
),
fullSection(
menu = "second",
center = TRUE,
h3("Slide"),
verbatimTextOutput("slide")
)
)
server <- function(input, output){
output$slide <- renderPrint({
input$fp_origin # returns menu
})
}
shinyApp(ui, server)
```