WeCodePixels / theia-sticky-sidebar

Glues your website's sidebars, making them permanently visible while scrolling.
MIT License
569 stars 209 forks source link

Recalc on click event #47

Closed LamineKessoum closed 6 years ago

LamineKessoum commented 7 years ago

Hi there, i want to recalc the height of sidebar when i have a click event, the recalc is automatically on resize and scroll events, and because i have a hidden content showed when click on button and that's make a changes on sidebar height. is there any way to recalc the when clicked on button ? something like $("#parent").on('click', '#mybutton', function(){ $("#mysidebar").trigger( /* recalc height */ ); } ); Thanks guys.

liviucmg commented 7 years ago

You could simply trigger a window resize or scroll event, which in turn repositions the sidebar. Something like this:

$("#parent").on('click', '#mybutton', function() {
    $(window).trigger('resize');
});

Let me know if it works.

LamineKessoum commented 6 years ago

Update: Problem Resolved after setting a timeout

$("#mybutton").on('click', function() { settimeout(function(){$(window).trigger('resize')},150)});