@@ -34,6 +34,7 @@ const DefaultType = {}
34
34
35
35
const CLASS_NAME_BACKDROP = 'sidebar-backdrop'
36
36
const CLASS_NAME_FADE = 'fade'
37
+ const CLASS_NAME_HIDE = 'hide'
37
38
const CLASS_NAME_SHOW = 'show'
38
39
const CLASS_NAME_SIDEBAR = 'sidebar'
39
40
const CLASS_NAME_SIDEBAR_NARROW = 'sidebar-narrow'
@@ -44,6 +45,7 @@ const REGEXP_SIDEBAR_SELF_HIDING = /sidebar-self-hiding/
44
45
45
46
const EVENT_HIDE = `hide${ EVENT_KEY } `
46
47
const EVENT_HIDDEN = `hidden${ EVENT_KEY } `
48
+ const EVENT_RESIZE = 'resize'
47
49
const EVENT_SHOW = `show${ EVENT_KEY } `
48
50
const EVENT_SHOWN = `shown${ EVENT_KEY } `
49
51
const EVENT_CLICK_DATA_API = `click${ EVENT_KEY } ${ DATA_API_KEY } `
@@ -94,6 +96,10 @@ class Sidebar extends BaseComponent {
94
96
show ( ) {
95
97
EventHandler . trigger ( this . _element , EVENT_SHOW )
96
98
99
+ if ( this . _element . classList . contains ( CLASS_NAME_HIDE ) ) {
100
+ this . _element . classList . remove ( CLASS_NAME_HIDE )
101
+ }
102
+
97
103
if ( REGEXP_SIDEBAR_SELF_HIDING . test ( this . _element . className ) ) {
98
104
this . _element . classList . add ( CLASS_NAME_SHOW )
99
105
}
@@ -124,6 +130,8 @@ class Sidebar extends BaseComponent {
124
130
125
131
if ( this . _element . classList . contains ( CLASS_NAME_SHOW ) ) {
126
132
this . _element . classList . remove ( CLASS_NAME_SHOW )
133
+ } else {
134
+ this . _element . classList . add ( CLASS_NAME_HIDE )
127
135
}
128
136
129
137
if ( this . _isMobile ( ) ) {
@@ -315,6 +323,18 @@ class Sidebar extends BaseComponent {
315
323
event . preventDefault ( )
316
324
this . hide ( )
317
325
} )
326
+
327
+ EventHandler . on ( window , EVENT_RESIZE , ( ) => {
328
+ // eslint-disable-next-line no-console
329
+ console . log ( 'resized' )
330
+ // eslint-disable-next-line no-console
331
+ console . log ( this . _mobile )
332
+ // eslint-disable-next-line no-console
333
+ console . log ( this . _show )
334
+ if ( this . _isMobile ( ) && this . _isVisible ( ) ) {
335
+ this . hide ( )
336
+ }
337
+ } )
318
338
}
319
339
320
340
// Static
0 commit comments