juba / shinyglide

Glide.js component for Shiny apps
https://juba.github.io/shinyglide/
91 stars 8 forks source link

Start glide on specific screen? #44

Closed analytichealth closed 11 months ago

analytichealth commented 11 months ago

Hi, Is it possible to start a glide on the nth screen? I got this to work with shinyjs, but ideally it would open on the specific screen rather than changing after opening.


library(shiny)
library(shinyglide)
library(shinyjs)

glide_controls <- glideControls(
  list(
    prevButton()
  ),
  list(
    tagAppendAttributes(
      id = "next_button",
      nextButton()
    )
  )
)

ui <- fluidPage(
  shinyjs::useShinyjs()
)

server <- function(input, output, session) {

  show_glide <- function() {
    showModal(
      modalDialog(
        glide(
          custom_controls = glide_controls,
          screen(
            p("Screen 1")
          ),
          screen(
            p("Screen 2")
          ),
          screen(
            p("Screen 3")
          )
        )
      )
    )
  }

  show_glide()

  shinyjs::click(id = "next_button")
}

shinyApp(ui, server)
juba commented 11 months ago

Hi,

I just added a start_at argument to th e glide() function in the development version. Let me know if it is working for you.

analytichealth commented 11 months ago

That works perfectly. Thanks so much for the quick update!