Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JohnCoene/shinyscroll
Scroll to an element in Shiny
https://github.com/JohnCoene/shinyscroll
r rstats shiny
Last synced: 3 months ago
JSON representation
Scroll to an element in Shiny
- Host: GitHub
- URL: https://github.com/JohnCoene/shinyscroll
- Owner: JohnCoene
- License: other
- Created: 2020-01-22T14:58:31.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T09:49:54.000Z (over 4 years ago)
- Last Synced: 2024-05-01T15:30:19.299Z (6 months ago)
- Topics: r, rstats, shiny
- Language: R
- Size: 272 KB
- Stars: 21
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - shinyscroll - Scroll to an element in Shiny. (UI Components / Advanced Interactivity)
- jimsghstars - JohnCoene/shinyscroll - Scroll to an element in Shiny (R)
README
# shinyscroll
Programatically scroll in Shiny.
## Installation
Install it with `remotes` from Github:
``` r
# install.packages("remotes")
remotes::install_github("JohnCoene/shinyscroll")
```## Example
{shinyscroll} was created to solve the use case below, where I want the window to scroll to a plot dynamically created by a click in a DT table.
``` r
library(DT)
library(shiny)
library(shinyscroll)ui <- fluidPage(
use_shinyscroll(),
h1("shinyscroll"),
p("Select a row"),
DTOutput("table"),
plotOutput("plot")
)server <- function(input, output, session){
output$table <- renderDT({
datatable(cars, selection = "single", options = list(pageLength = 20L))
})dataset <- eventReactive(input$table_rows_selected, {
scroll("plot") # scroll to plot
runif(100)
})output$plot <- renderPlot(plot(dataset()))
}shinyApp(ui, server)
```![](./man/figures/shinyscroll.gif)
It's also used in the DXY tab of the [coronavirus tracker](http://shiny.john-coene.com/coronavirus)