waypoints: Waypoint

Description Public fields Active bindings Methods Examples

Description

A waypoint object to track.

Public fields

up, down

Whether waypoint has been passed on the up or down.

direction

Direction in which waypoint is going.

Active bindings

up, down

Whether waypoint has been passed on the up or down.

Methods

Public methods


Method new()

Usage
Waypoint$new(
  id,
  animate = FALSE,
  animation = "shake",
  offset = NULL,
  horizontal = FALSE,
  waypoint_id = NULL,
  start = TRUE
)
Arguments
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.

Details

Initialise


Method start()

Usage
Waypoint$start()
Details

Start watching the waypoint.


Method destroy()

Usage
Waypoint$destroy()
Details

Destroy the waypoint.


Method enable()

Usage
Waypoint$enable()
Details

Enable the waypoint.


Method disable()

Usage
Waypoint$disable()
Details

Disable the waypoint.


Method animate()

Usage
Waypoint$animate(animation = NULL)
Arguments
animation

Animation to use.

Details

Animate the waypoint.


Method get_direction()

Usage
Waypoint$get_direction()
Details

Get direction in which user is scrolling past the waypoint


Method going_up()

Usage
Waypoint$going_up()
Details

Whether user is scrolling up past the waypoint.


Method going_down()

Usage
Waypoint$going_down()
Details

Whether user is scrolling down past the waypoint.


Method get_triggered()

Usage
Waypoint$get_triggered()
Details

Whether waypoint has been triggered.


Method clone()

The objects of this class are cloneable with this method.

Usage
Waypoint$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

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
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)

RinteRface/waypointer documentation built on Feb. 2, 2020, 7:46 p.m.