trafficonese / leaflet.extras

Extra functionality for leaflet R package.
https://trafficonese.github.io/leaflet.extras/
GNU General Public License v3.0
211 stars 74 forks source link

suspendScroll no longer working #194

Closed micahwilhelm closed 4 months ago

micahwilhelm commented 4 years ago

Example: leaflet(width = "100%") %>% setView(0, 0, 1) %>% addTiles() %>% suspendScroll(hoverToWake = FALSE)

See original issue comment here: https://github.com/rstudio/leaflet/issues/464#issuecomment-535424913

trafficonese commented 5 months ago

I think it works as expected. You need to add some content to a shiny-app, so you can/have to scroll over the map. The scroll will not get trapped immediately from leaflet. But you will trigger the zoom, when you put the cursor on the map and then scroll.

library(shiny)  
library(leaflet)
library(leaflet.extras)

ui <- fluidPage(
  HTML(rep(as.character(tags$br()), 30)),
  leafletOutput("map"),
  HTML(rep(as.character(tags$br()), 40)),
)

server <- function(input, output, session) {
  output$map <- renderLeaflet({
    leaflet() %>%
      addTiles() %>%
      suspendScroll(hoverToWake = FALSE, 
                    wakeTime = 2000,
                    wakeMessage =  "Click to Wake")
  })
}
shinyApp(ui, server)