Title: | Animation for 'shiny' Elements |
---|---|
Description: | An extension of 'animate.css' that allows user to easily add animations to any UI element in 'shiny' app using the elements id. |
Authors: | Swechhya Bista |
Maintainer: | Swechhya Bista <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.0 |
Built: | 2024-11-08 04:27:27 UTC |
Source: | https://github.com/swechhya/shinyanimate |
Add animation on mouse hover for UI element.
addHoverAnim(session, id, type = NULL)
addHoverAnim(session, id, type = NULL)
session |
The session object passed to function given to shinyServer. |
id |
the id of the UI element for which you want animation on mouse hover. |
type |
The type of animation to use, valid values correspond to the types in https://daneden.github.io/animate.css/ |
if(interactive()){ library(shiny) library(shinyanimate) ui <- fluidPage( withAnim(), tags$div(id = 'title', h1('HOVER ON ME')) ) server <- function(input, output, session){ observe(addHoverAnim(session, 'title', 'bounce')) } shinyApp(ui, server) }
if(interactive()){ library(shiny) library(shinyanimate) ui <- fluidPage( withAnim(), tags$div(id = 'title', h1('HOVER ON ME')) ) server <- function(input, output, session){ observe(addHoverAnim(session, 'title', 'bounce')) } shinyApp(ui, server) }
Add animation on scroll for UI element.
addScrollAnim(session, id, type = NULL)
addScrollAnim(session, id, type = NULL)
session |
The session object passed to function given to shinyServer. |
id |
the id of the UI element for which you want animation on scroll. |
type |
The type of animation to use, valid values correspond to the types in https://daneden.github.io/animate.css/ |
if(interactive()){ library(shiny) library(shinyanimate) ui <- fluidPage( withAnim(), tags$h1('Scroll below to see an animation'), 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(), tags$div(id = 'title', h1('I ANIMATE ON SCROLL')) ) server <- function(input, output, session){ observe(addScrollAnim(session, 'title', 'bounce')) } shinyApp(ui, server) }
if(interactive()){ library(shiny) library(shinyanimate) ui <- fluidPage( withAnim(), tags$h1('Scroll below to see an animation'), 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(), tags$div(id = 'title', h1('I ANIMATE ON SCROLL')) ) server <- function(input, output, session){ observe(addScrollAnim(session, 'title', 'bounce')) } shinyApp(ui, server) }
Start an animation of the UI element.
startAnim(session, id, type = NULL, delay = NULL)
startAnim(session, id, type = NULL, delay = NULL)
session |
The session object passed to function given to shinyServer. |
id |
the id of the UI element for which you want to add animation. |
type |
The type of animation to use, valid values correspond to the types in https://daneden.github.io/animate.css/ |
delay |
The time after which you want to add animationin milliseconds |
if(interactive()){ library(shiny) library(shinyanimate) ui <- fluidPage( withAnim(), tags$div(id = 'title', h1('ANIMATION')), actionButton(inputId = "button", label = "Animate") ) server <- function(input, output, session){ observeEvent(input$button,{ startAnim(session, 'title', 'bounce') }) } shinyApp(ui, server) }
if(interactive()){ library(shiny) library(shinyanimate) ui <- fluidPage( withAnim(), tags$div(id = 'title', h1('ANIMATION')), actionButton(inputId = "button", label = "Animate") ) server <- function(input, output, session){ observeEvent(input$button,{ startAnim(session, 'title', 'bounce') }) } shinyApp(ui, server) }
This function needs to be added in the UI if to want to add animation to your UI elements using shinyanimate.
withAnim()
withAnim()
if(interactive()){withAnim()}
if(interactive()){withAnim()}