juba / shinyglide

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

Is possible to send the user back to the first screen using a shiny::actionButton() that is positioned outside of shinyglide::screen()? #40

Closed JulianoAtto closed 1 year ago

JulianoAtto commented 1 year ago

Hi,

I want to create a button that is positioned outside the shinyglide::screen's() that enables the user to reset the glide at any moment (any screen). One of the main requirements to reset is to send the user to the first screen.

I tried to use the code below but it only works inside some shinyglide::screen() and besides that I need it to be a shiny::actionButton() so that I can shiny::observeEvent() and execute other needed actions in my app during the reset.

div(`data-glide-el`="controls",
   tags$button(`data-glide-dir`="<<", href="#", "Back to start")
)

Also I checked the glide.js documentation and noticed that there is the following code that sends the user to the initial screen:

var glide = new Glide('.glide').mount()

glide.go('<<')

Is there any workaround to run this javascript code to control the shinyglide::glide() inside an shiny::observeEvent()?

juba commented 1 year ago

By using shinyglide control options you wouldn't be able to put such a control outside of screen(). As far as I know the only other way to do it would be in pure Javascript, but that would mean being able to get back an already mounted glide object and I'm not sure the glide.js API allows to do it...

JulianoAtto commented 1 year ago

Ok, thanks. I'll find another way to do this