File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -53,13 +53,26 @@ document.addEventListener('DOMContentLoaded', () => {
5353 }
5454} ) ;
5555
56- window . addEventListener ( 'resize' , ( ) => {
57- const sidebar = document . getElementById ( 'sidebar-v2' ) ;
56+ const debounce = ( callback , wait ) => {
57+ let timeoutId = null ;
58+ return ( ...args ) => {
59+ window . clearTimeout ( timeoutId ) ;
60+ timeoutId = window . setTimeout ( ( ) => {
61+ callback ( ...args ) ;
62+ } , wait ) ;
63+ } ;
64+ } ;
5865
59- if (
60- window . innerWidth > 88 * 16 &&
61- sidebar . classList . contains ( 'sidebar__mobile-open' )
62- ) {
63- sidebar . classList . remove ( 'sidebar__mobile-open' ) ;
64- }
65- } ) ;
66+ window . addEventListener (
67+ 'resize' ,
68+ debounce ( ( ) => {
69+ const sidebar = document . getElementById ( 'sidebar-v2' ) ;
70+
71+ if (
72+ window . innerWidth > 88 * 16 &&
73+ sidebar . classList . contains ( 'sidebar__mobile-open' )
74+ ) {
75+ sidebar . classList . remove ( 'sidebar__mobile-open' ) ;
76+ }
77+ } , 200 )
78+ ) ;
You can’t perform that action at this time.
0 commit comments