File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change
1
+ const updateMenuPositionForSubMenu = ( currentMenuSupplier ) => {
2
+ const currentMenu = currentMenuSupplier ( ) ;
3
+ const subMenu = currentMenu ?. getElementsByClassName ( 'pure-menu-children' ) ?. [ 0 ] ;
4
+
5
+ subMenu ?. style . setProperty ( '--menu-x' , `${ currentMenu . getBoundingClientRect ( ) . x } px` ) ;
6
+ }
7
+
1
8
// Allow menus to be open and used by keyboard.
2
9
( function ( ) {
3
10
var currentMenu ;
4
11
var backdrop = document . createElement ( "div" ) ;
5
12
backdrop . style = "display:none;position:fixed;width:100%;height:100%;z-index:1" ;
6
13
document . documentElement . insertBefore ( backdrop , document . querySelector ( "body" ) ) ;
14
+
15
+ addEventListener ( 'resize' , ( ) => updateMenuPositionForSubMenu ( ( ) => currentMenu ) ) ;
16
+
7
17
function previous ( allItems , item ) {
8
18
var i = 1 ;
9
19
var l = allItems . length ;
52
62
this . blur ( ) ;
53
63
} else {
54
64
if ( currentMenu ) closeMenu ( ) ;
65
+
66
+ updateMenuPositionForSubMenu ( ( ) => this . parentNode ) ;
67
+
55
68
openMenu ( this . parentNode ) ;
56
69
}
57
70
e . preventDefault ( ) ;
Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ div.nav-container {
50
50
}
51
51
}
52
52
53
+ .pure-menu-has-children.pure-menu-active > .pure-menu-link {
54
+ & :after {
55
+ content :" \25B2 " ;
56
+ }
57
+ }
58
+
53
59
.pure-menu-link {
54
60
font-size : 12.8px ;
55
61
font-weight : 400 ;
@@ -133,11 +139,20 @@ div.nav-container {
133
139
}
134
140
135
141
.pure-menu-children {
142
+ --menu-x : 0 ;
143
+
144
+ // #{} interpolates a SassScript expression. Using this prevents
145
+ // SASS from using its built-in min/max over the CSS min/max functions
146
+ --clamped-offset : m#{i} n (var (--menu-x ), calc (100vw - 100% ));
147
+
136
148
border : 1px solid var (--color-border );
137
149
border-radius : 0 0 2px 2px ;
138
- margin-left : -1px ;
139
150
background-color : var (--color-background );
140
151
152
+ left : 0 ;
153
+ position : fixed ;
154
+ transform : translateX (m#{a}x(0% , var (--clamped-offset )));
155
+
141
156
li {
142
157
border-left : none ;
143
158
}
You can’t perform that action at this time.
0 commit comments