Preventing Endless JS Interval
-
Hi,
I have an issue with your plugin code.
The script fires a jQuery UI resizable() on the sidebar element every 500 milliseconds.
This could be prevented if the interval is cleared once the sidebar is present and thewidth()
,resizable()
anddetermine_if_sidebar_open()
have been applied.My proposal for a change:
let interval = setInterval(function(){
jQuery('.interface-interface-skeleton__sidebar').width(localStorage.getItem('toast_rs_personal_sidebar_width'))
jQuery('.interface-interface-skeleton__sidebar').resizable({
handles: 'w',
resize: function(event, ui) {
jQuery(this).css({'left': 0});
localStorage.setItem('toast_rs_personal_sidebar_width', jQuery(this).width());
}
});
determine_if_sidebar_open();
if ( 0 < jQuery('.interface-interface-skeleton__sidebar').length ) {
clearInterval( interval );
}
}, 500);Thanks a lot,
Johann
- You must be logged in to reply to this topic.