scroll_reveal: Animate elements when scrolling to view them

Description Usage Arguments Value Examples

View source: R/scroll_reveal.R

Description

Animate elements when scrolling to view them

Usage

1
2
3
4
5
6
7
8
scroll_reveal(
  target,
  duration = 1000,
  delay = 100,
  distance = "20px",
  origin = "bottom",
  reset = TRUE
)

Arguments

target

The elements to animate as they scroll into view

duration

The duration of the animation in milliseconds. Defaults to 1000 ms

delay

The desired delay in milliseconds before triggering the animation. Defaults to 100 ms

distance

Controls how far elements move when revealed. Defaults to 20px

origin

Specifies what direction elements come from when revealed ("top", "bottom", "right", "left"). Defaults to "bottom"

reset

logical, should the function animate the element each time it scrolls into view or only once. Defaults to TRUE.

Value

An animated shiny element

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if (interactive()) {

ui <- fluidPage(
h1("TIME"),
br(),
br(),
h1("SPACE"),
br(),
br(),
h1("PIZZA"),
br(),
br(),
br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(),
br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(),
br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(),
br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br(),

# Using the scroll_reveal() function
scroll_reveal(target = "h1", duration = 2000, distance = "100px"),

)
server <- function(input, output) {

}

shinyApp(ui = ui, server = server)
}

Example output



scrollrevealR documentation built on Oct. 23, 2020, 6:09 p.m.