fix(sticky main menu): corrige le comportement en cas de resize; participe à #1
Parent
29f6667a95
révision
dd2187cd8e
|
@ -2,4 +2,5 @@ biohdf/static/css/app.css.map -diff
|
|||
biohdf/static/css/app.min.css -diff
|
||||
biohdf/static/css/app.css -diff
|
||||
biohdf/static/js/app.js -diff
|
||||
biohdf/static/js/app.min.js -diff
|
||||
biohdf/static/js/app.js.map -diff
|
||||
|
|
|
@ -3,15 +3,16 @@ import $ from 'jquery';
|
|||
$(() => {
|
||||
const navbar = $('.mainmenu');
|
||||
const sticky = navbar.offset().top;
|
||||
let width = navbar.width();
|
||||
let width = navbar.parent().width();
|
||||
|
||||
$(window).resize(() => {
|
||||
width = navbar.width();
|
||||
width = navbar.parent().width();
|
||||
$(window).trigger('scroll');
|
||||
});
|
||||
|
||||
$(window).scroll(() => {
|
||||
if (window.pageYOffset >= sticky) {
|
||||
navbar.css('width', `calc(${width}px + 2rem)`);
|
||||
navbar.css('width', `${width}px`);
|
||||
navbar.addClass('sticky');
|
||||
} else {
|
||||
navbar.removeClass('sticky');
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket