Title: | Animate on Scroll Library for 'shiny' |
---|---|
Description: | Trigger animation effects on scroll on any HTML element of 'shiny' and 'rmarkdown', such as any text or plot, thanks to the 'AOS' Animate On Scroll jQuery library <http://michalsnik.github.io/aos/>. |
Authors: | Félix Luginbuhl [aut, cre] |
Maintainer: | Félix Luginbuhl <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-01-14 05:07:22 UTC |
Source: | https://github.com/lgnbhl/aos |
Animate on scroll a Shiny or R Markdown element.
aos( element, animation, offset = "120", duration = "400", easing = "ease", delay = "0", anchor = "", anchor_placement = "top-bottom", once = FALSE, ... )
aos( element, animation, offset = "120", duration = "400", easing = "ease", delay = "0", anchor = "", anchor_placement = "top-bottom", once = FALSE, ... )
element |
An shiny or rmarkdown element. |
animation |
An animation from AOS |
offset |
string. Change offset to trigger animations sooner or later, px |
duration |
string. Duration of animation in ms |
easing |
string. Choose timing function to ease elements in different ways |
delay |
string. Delay animation in ms |
anchor |
string. Anchor placement |
anchor_placement |
string. Anchor placement - which one position of element on the screen should trigger animation |
once |
boolean. |
... |
Additional class element |
Javascript code animating the element.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( use_aos(), # add use_aos() in the UI aos(h1("Shiny with AOS - Animate On Scroll"), animation = "fade-zoom-in"), aos(textOutput("text"), animation = "fade-up") ), server <- function(input, output, session){ output$text <- renderText({ print("An animated text.") }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( use_aos(), # add use_aos() in the UI aos(h1("Shiny with AOS - Animate On Scroll"), animation = "fade-zoom-in"), aos(textOutput("text"), animation = "fade-up") ), server <- function(input, output, session){ output$text <- renderText({ print("An animated text.") }) } ) }
Get aos html dependencies.
html_dependencies_aos(use_cdn = TRUE)
html_dependencies_aos(use_cdn = TRUE)
use_cdn |
boolean. TRUE to use a Content Delivery Network (CDN), true by default, or false to use locally stored files. |
Use aos
use_aos( disable = FALSE, startEvent = "DOMContentLoaded", initClassName = "aos-init", animatedClassName = "aos-animate", useClassNames = FALSE, disableMutationObserver = FALSE, debounceDelay = "50", throttleDelay = "99", offset = "120", duration = "400", easing = "ease", delay = "0", use_cdn = TRUE )
use_aos( disable = FALSE, startEvent = "DOMContentLoaded", initClassName = "aos-init", animatedClassName = "aos-animate", useClassNames = FALSE, disableMutationObserver = FALSE, debounceDelay = "50", throttleDelay = "99", offset = "120", duration = "400", easing = "ease", delay = "0", use_cdn = TRUE )
disable |
string. Condition when AOS should be disabled, for example 'mobile' |
startEvent |
string. Name of the event dispatched on the document, that AOS should initialize on |
initClassName |
string. Class applied after initialization |
animatedClassName |
string. Class applied on animation |
useClassNames |
boolean. If true, will add content of data-aos as classes on scroll |
disableMutationObserver |
boolean. Disables automatic mutations detections (advanced) |
debounceDelay |
string. The delay on debounce used while resizing window (advanced) |
throttleDelay |
string. The delay on throttle used while scrolling the page (advanced) |
offset |
string. Change offset to trigger animations sooner or later, in px |
duration |
string. Duration of animation in ms. |
easing |
string. Timing function to animate elements nicely |
delay |
string. Delay animation (ms) |
use_cdn |
boolean. TRUE to use a Content Delivery Network (CDN), true by default, or false to use locally stored files. |
Javascript code initializing aos with dependencies.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( use_aos(), # add use_aos() in the UI aos(h1("Shiny with AOS - Animate On Scroll"), animation = "fade-zoom-in"), aos(textOutput("text"), animation = "fade-up") ), server <- function(input, output, session){ output$text <- renderText({ print("An animated text.") }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( use_aos(), # add use_aos() in the UI aos(h1("Shiny with AOS - Animate On Scroll"), animation = "fade-zoom-in"), aos(textOutput("text"), animation = "fade-up") ), server <- function(input, output, session){ output$text <- renderText({ print("An animated text.") }) } ) }
Recalculate all offsets and positions of elements (called on window resize).
use_aos_refresh()
use_aos_refresh()
By default AOS is watching for DOM changes and if there are any new elements loaded asynchronously or when something is removed from DOM it calls refreshHard automatically. In browsers that don't support MutationObserver like IE you might need to call AOS.refreshHard() by yourself.
Javascript code
use_aos_refresh()
use_aos_refresh()
Reinit array with AOS elements and trigger refresh (called on DOM changes that are related to aos elements)
use_aos_refresh_hard()
use_aos_refresh_hard()
Javascript code
use_aos_refresh_hard()
use_aos_refresh_hard()