File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
guides/assets/javascripts Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 52
52
} ) ;
53
53
}
54
54
55
+ // Detecting the mobile state should be done using CSS because that's what
56
+ // lays out the page, but this can fallback to JavaScript if that is not
57
+ // available
58
+ var MOBILE_WIDTH_FROM_STYLE_CSS_BREAKPOINT = 1024
59
+ var isMobile = window . innerWidth <= MOBILE_WIDTH_FROM_STYLE_CSS_BREAKPOINT ;
60
+
61
+ if ( 'matchMedia' in window ) {
62
+ var mediaQueryList = window . matchMedia ( `(max-width: ${ MOBILE_WIDTH_FROM_STYLE_CSS_BREAKPOINT } px)` ) ;
63
+ isMobile = mediaQueryList . matches ? 'auto' : 'smooth' ;
64
+
65
+ mediaQueryList . addEventListener ( 'change' , function ( ev ) {
66
+ isMobile = ev . matches ? 'auto' : 'smooth' ;
67
+ } ) ;
68
+ } else {
69
+ window . addEventListener ( 'resize' , function onResize ( ) {
70
+ isMobile = window . innerWidth <= MOBILE_WIDTH_FROM_STYLE_CSS_BREAKPOINT
71
+ } )
72
+ }
73
+
55
74
// The guides menu anchor is overridden to expand an element with the entire
56
75
// index on the same page. It is important that both the visibility is
57
76
// changed and that the aria-expanded attribute is toggled.
344
363
return ;
345
364
}
346
365
366
+ // Must match breakpoints.desktop in style.scss
367
+ if ( isMobile ) {
368
+ return
369
+ }
370
+
347
371
// On some OS-browser combinations, this will stop smooth scrolling of the
348
372
// main document if scroll-behaviour: smooth or vice-versa (this element
349
373
// stopping when clicking a link). This is also the case with setting
You can’t perform that action at this time.
0 commit comments