trafficonese / leaflet.extras

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

Full Screen Button Misbehaves in HTML Documents #41

Closed tiernanmartin closed 7 years ago

tiernanmartin commented 7 years ago

It seems that the addFullscreenControl() feature fails to recognize the screen extents when it is included in an html document (e.g., r notebook, gitbook, etc.).

To reproduce this error, run the following example, knit an html document, and try toggling the full screen button:

---
output:
  html_document: default
---

*```{r setup}
library(leaflet)
library(leaflet.extras)

leaflet() %>% 
        addTiles() %>% 
        setView(-93.65, 42.0285, zoom = 17) %>% 
        addFullscreenControl()
*```

Using Chrome, I get the following result:

screen shot 2016-12-05 at 9 13 26 am

After clicking the full screen button: screen shot 2016-12-05 at 9 13 38 am

Any suggestions for short-term fix work-arounds would be welcome – thanks!

bhaskarvk commented 7 years ago

I can't reproduce this. It works fine for me in w/ Chrome/firefox/safari under OSx. Do you see any errors in the JS console ?

Could you try this page and see what happens ? http://rstudio-pubs-static.s3.amazonaws.com/233091_8128d9ed27b84b86ad0573a3b0720073.html

Mind you the full screen control won't work in RPUBs because Rpubs embeds the knitted HTML in an iframe.

byzheng commented 7 years ago

I believe this is caused by the same problem with shinydashboard and leaflet package. See here: https://github.com/rstudio/leaflet/issues/248

@jcheng5 uses this code to solve it

tags$script(
     '$(".sidebar-toggle").on("click", function() { $(this).trigger("shown"); });'
 )

Not sure how to solve in this case.

bhaskarvk commented 7 years ago

It could be similar issue, but then it should be easily reproducible. I couldn't reproduce it using either safari/chrome/firefox.

tiernanmartin commented 7 years ago

Wow... I have been wrestling with this problem for the last week, and now that @bhaskarvk can't reproduce it neither can I! I'm dumbfounded.

I feel a little uneasy because I'm still unsure of why it was misbehaving to begin with, but for now it seems to have fixed itself.

Feel free to close this issue for now - with any luck this was just a weird gotcha that no one else will have to deal with.

Thanks!

tiernanmartin commented 7 years ago

It turns out this issue only occurs when a user has their Chrome browser in fullscreen mode, and the issue has been documented.

bhaskarvk commented 7 years ago

I think I can add an option 'pseudofullscreen' to the R function as well. That way you can make it work in Chrome browser fullscreen mode by setting pseudofullscreen = true

bhaskarvk commented 7 years ago

Added pseudoFullScreen option. Demo http://rpubs.com/bhaskarvk/fullscreen.