daattali / shinyjs

💡 Easily improve the user experience of your Shiny apps in seconds
https://deanattali.com/shinyjs
Other
734 stars 119 forks source link

shiny dashboard: detect toggle sidebar event #178

Closed paul-shannon closed 5 years ago

paul-shannon commented 5 years ago

When I hide the dashboard sidebar, I need to call "redraw" on my igvShiny widget. As written, igv.js does not detect css class changes, so it does not resize itself automatically to take advantage of the new space created.

I have searched up and down, consulted the shinyjs docs, but nowhere have I found a way to detect the button click, or the changed width of the sidebar.

Any suggestions on how to programmatically detect the collapse icon click, or the resizing of the sidebar?

daattali commented 5 years ago

This is not a shinyjs question, it's a purely javascript question. shinyjs is meant to facilitate the interaction between R and Javascript, but this is straight up javascript. I don't know off the top of my head how to solve this in javascript, I would guess the easiest thing to do is to hook up an event listener to the icon with something like jQuery's click() function. If you don't know enough javascript to be able to consult the jquery docs, I suggest asking on a javascript-focused forum.