Description Public fields Active bindings Methods Examples
A waypoint object to track.
up, down
Whether waypoint has been passed on the up or down.
direction
Direction in which waypoint is going.
up, down
Whether waypoint has been passed on the up or down.
new()
Waypoint$new( id, animate = FALSE, animation = "shake", offset = NULL, horizontal = FALSE, waypoint_id = NULL, start = TRUE )
id
Id of element to use as waypoint.
animate
Whether to animate element when the waypoint is triggered.
animation
Animation to use if animate
is set.
offset
Offset relative to viewport to trigger the waypoint.
horizontal
Set to TRUE
if using horizontally.
waypoint_id
Id of waypoint, useful to get the input value.
start
Whether to automatically start watching the waypoint.
Initialise
start()
Waypoint$start()
Start watching the waypoint.
destroy()
Waypoint$destroy()
Destroy the waypoint.
enable()
Waypoint$enable()
Enable the waypoint.
disable()
Waypoint$disable()
Disable the waypoint.
animate()
Waypoint$animate(animation = NULL)
animation
Animation to use.
Animate the waypoint.
get_direction()
Waypoint$get_direction()
Get direction in which user is scrolling past the waypoint
going_up()
Waypoint$going_up()
Whether user is scrolling up past the waypoint.
going_down()
Waypoint$going_down()
Whether user is scrolling down past the waypoint.
get_triggered()
Waypoint$get_triggered()
Whether waypoint has been triggered.
clone()
The objects of this class are cloneable with this method.
Waypoint$clone(deep = FALSE)
deep
Whether to make a deep clone.
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 28 29 30 31 32 33 34 35 36 37 | library(shiny)
ui <- fluidPage(
use_waypointer(),
div(
h1("Scroll down"),
style = "min-height:90vh"
),
verbatimTextOutput("result"),
plotOutput("plot"),
div(style = "min-height:90vh")
)
server <- function(input, output, session) {
w <- Waypoint$
new("plot", offset = "20%")$
start()
output$result <- renderPrint({
w$get_direction()
})
output$plot <- renderPlot({
req(w$get_direction())
if(w$get_direction() == "down")
hist(runif(100))
else
""
})
}
if(interactive()) shinyApp(ui, server)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.