Closed ismirsehregal closed 3 years ago
thanks for opening the issue, will investigate
This should fix the problem which was having the same ID for two elements in the app.
you can install this branch and it should run fine
The reactive text will observing the carousels will be attached to the last carousel built ie if only 1 carousel the slick1 if two carousels it will track slick2
here is the specific fix:
output$slick_output <- renderSlickR({
x <- slickR(plots(),
slideId = 'slick1',
height = 600,
width = '50%') +
settings(slidesToShow=3,centerMode=TRUE)
y <- slickR(plots(),
slideId = 'slick2',
height = 600,
width = '50%') +
settings(slidesToShow=3,centerMode=TRUE)
switch(input$slick_type,
'single' = x,
'stack' = x %stack% y,
'synch' = x %synch% y
)
})
Thanks for the very fast update!
With the new version when i switch from single to stack all is fine. When I then switch to synch I have 3 carousels, back to stack and there are 4.
It's piling up new carousels:
ha nice. i'll take another look
try this commit https://github.com/yonicd/slickR/commit/417fd60e013b70540970c1b798897050c3580d2c it should accommodate multiple sliders in the same app including the observers to know which is active
Using your latest commit the vignette runs fine! Thanks for your time and effort!
Just saw that the description given in the vignette needs to be aligned with the actual outputs:
.clicked_slide != .clicked etc. (_slide suffix needs to be removed.. or added)
Using this you can interact server-side "on click" of the active carousel
by accessing elements in input$slick_output_current$
.clicked _slide : The index of the clicked element| .relative_clicked: The relative position of the clicked element| .center _slide : The index of the center element| .total _slide : The total number of elements in the carousel| .active _slide : The ID of the active carousel|
We will store this information in a new reactive environment active_slick <- shiny::reactiveValues()
shiny::observeEvent(input$slick_output_current,{
clicked_slide <- input$slick_output_current$.clicked relative_clicked <- input$slick_output_current$.relative_clicked center_slide <- input$slick_output_current$.center total_slide <- input$slick_output_current$.total active_slide <- input$slick_output_current$.slide
Thanks for the comment 👍
I just realized, that when using https://github.com/yonicd/slickR/commit/417fd60e013b70540970c1b798897050c3580d2c there still is an issue: when stack is selected and we are going back to single both carousels remain.
Furthermore library(gdtools)
should be added to the vignette.
After a fresh R install:
package or namespace load failed for ‘svglite’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘gdtools’
(svglite was installed via: install.packages("svglite", dependencies = TRUE)
)
you are right.
the way the js is written only 1 slider is being removed because it is removing based on the number of slicks that are being created and not the existing ones.
so when moving from 2 to 1 it is looking for only 1. the original code was written assuming you are updating the same number of slicks every time.
this should fix the issue https://github.com/yonicd/slickR/commit/3505e63400bce35a4b321a03bc4c43e3556a42f8
closed with pr https://github.com/yonicd/slickR/pull/56
I just tried to run the slickR shiny vignette but it seems to be broken.
Once the
radioButtons
are used to switch to stacked or synch mode theinput$slick_output_current
isn't providing any data. Also the lower carousel isn't rendered properly: