Skip to content

Commit 181adba

Browse files
committed
adjust footer submenus to open upwards
1 parent 44a9640 commit 181adba

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

src/assets/js/customizer/color/preview.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ export class Preview {
452452
css += `#${location}-menu.sm-clean > li.menu-item:not( .custom-sub-menu ) > ul.sub-menu:not(.custom-sub-menu):before,
453453
#${location}-menu.sm-clean > li.menu-item:not( .custom-sub-menu ) > ul.sub-menu:not(.custom-sub-menu):after {
454454
border-color: transparent transparent ${subcolorVariable} transparent;
455+
}
456+
#${location}-menu.sm-clean > li.menu-item:not( .custom-sub-menu ) > ul.sub-menu.pointer-bottom:not(.custom-sub-menu):after {
457+
border-color: ${subcolorVariable} transparent transparent transparent;
455458
}`;
456459
css += '}';
457460

src/assets/js/front-end.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,7 @@ var BoldGrid = BoldGrid || {};
630630
sm.on( {
631631
'show.smapi': function( e, menu ) {
632632
$( menu ).removeClass( 'hide-animation' ).addClass( 'show-animation' );
633-
if ( $( menu ).is( '.custom-sub-menu' ) ) {
634-
BoldGrid.standard_menu_enabled.fixSubmenuOffset( menu );
635-
}
633+
BoldGrid.standard_menu_enabled.fixSubmenuOffset( menu );
636634
},
637635
'hide.smapi': function( e, menu ) {
638636
$( menu ).removeClass( 'show-animation' ).addClass( 'hide-animation' );
@@ -674,12 +672,27 @@ var BoldGrid = BoldGrid || {};
674672
},
675673

676674
// Fixes the offset of custom submenus so they don't go off screen
677-
fixSubmenuOffset( sm ) {
678-
var $subMenu = $( sm ),
679-
leftOffset = $subMenu.offset().left,
680-
subMenuWidth = $subMenu.children( 'li' ).outerWidth(),
681-
rightOffset = $( window ).outerWidth( true ) - ( leftOffset + subMenuWidth );
675+
fixSubmenuOffset( subMenu ) {
676+
var $subMenu = $( subMenu ),
677+
leftOffset = $subMenu.offset().left,
678+
bottomOffset = $subMenu.offset().top + $subMenu.outerHeight( true ),
679+
$headerContainer = $subMenu.closest( '#masthead' ).length ? $subMenu.closest( '#masthead' ) : $subMenu.closest( '#colophon' ),
680+
pointerHeight = 9,
681+
headerBottom = $headerContainer.offset().top + $headerContainer.outerHeight(),
682+
subMenuWidth = $subMenu.children( 'li' ).outerWidth(),
683+
subMenuHeight = $subMenu.outerHeight( true ) + pointerHeight,
684+
rightOffset = $( window ).outerWidth( true ) - ( leftOffset + subMenuWidth );
685+
686+
// Adjust the offset for menu items in the footer so it opens upwards instead of down.
687+
if ( bottomOffset > headerBottom && $subMenu.closest( '#colophon' ).length ) {
688+
$subMenu.css( {
689+
top: '-' + subMenuHeight + 'px'
690+
} );
691+
692+
$subMenu.addClass( 'pointer-bottom' );
693+
}
682694

695+
// Adjust left or right offset if submenu goes off screen.
683696
if ( 0 > rightOffset ) {
684697
$subMenu.css( 'left', rightOffset );
685698
}

src/assets/scss/boldgrid/navigation/_base.scss

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
.sm-clean.nw,
201201
.sm-clean.sw {
202202
&:not( .sm-vertical ) {
203-
li.menu-item:first-of-type a {
203+
> li.menu-item:first-of-type a {
204204
padding-left: 0px;
205205
}
206206
}
@@ -211,7 +211,7 @@
211211
.sm-clean.ne,
212212
.sm-clean.se {
213213
&:not( .sm-vertical ) {
214-
li.menu-item:last-of-type a {
214+
> li.menu-item:last-of-type a {
215215
padding-right: 0px;
216216
}
217217
}
@@ -285,12 +285,24 @@
285285
border-style: dashed dashed solid dashed;
286286
border-color: transparent transparent #bbbbbb transparent;
287287
}
288+
.sm-clean > li.menu-item > ul.sub-menu.pointer-bottom:not(.custom-sub-menu):before,
289+
.sm-clean > li.menu-item > ul.sub-menu.pointer-bottom:not(.custom-sub-menu):after {
290+
top: unset;
291+
bottom: -18px;
292+
border-style: solid dashed dashed dashed;
293+
border-color: #bbbbbb transparent transparent transparent;
294+
}
288295
.sm-clean > li.menu-item > ul.sub-menu:not(.custom-sub-menu):after {
289296
top: -16px;
290297
left: 31px;
291298
border-width: 8px;
292299
border-color: transparent transparent white transparent;
293300
}
301+
.sm-clean > li.menu-item > ul.sub-menu.pointer-bottom:not(.custom-sub-menu):after {
302+
top: unset;
303+
bottom: -16px;
304+
border-color: white transparent transparent transparent;
305+
}
294306
.sm-clean ul.sub-menu:not(.custom-sub-menu) {
295307
border: 1px solid #bbbbbb;
296308
padding: 5px 0;

src/includes/class-boldgrid-framework-styles.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ public function menu_css( $location ) {
554554
$css .= "#{$location}-menu.sm-clean > li.menu-item:not( .custom-sub-menu ) > ul.sub-menu:not(.custom-sub-menu):after ";
555555
$css .= "{ border-color: transparent transparent var(--{$submenu_background_class}) transparent; }";
556556

557+
$css .= "#{$location}-menu.sm-clean > li.menu-item:not( .custom-sub-menu ) > ul.sub-menu.pointer-bottom:not(.custom-sub-menu):before, ";
558+
$css .= "#{$location}-menu.sm-clean > li.menu-item:not( .custom-sub-menu ) > ul.sub-menu.pointer-bottom:not(.custom-sub-menu):after ";
559+
$css .= "{ border-color: var(--{$submenu_background_class}) transparent transparent transparent; }";
560+
557561
$css .= '}';
558562

559563
return $css;

0 commit comments

Comments
 (0)