Post by dani888 » Fri Dec 28, 2018 10:03 pm

Hello everyone
What do I have to add to this code?
sticky menu and stay on top with the search button and shopping cart
The cod is
$(function(){
var div = '#m-menu';
var windowScrollTop = $(window).scrollTop();
var divOffsetTop = $(div).offset().top;
if(windowScrollTop > divOffsetTop){
$(div).addClass('sticky');
} else {
$(div).removeClass('sticky');
}

$(window).on('scroll', function(){
var windowScrollTop = $(window).scrollTop();
if(windowScrollTop > divOffsetTop){
$(div).addClass('sticky');
} else {
$(div).removeClass('sticky');
}
});
});
And Css code
#m-menu.sticky {
position: fixed;
left: 0;
right: 0;
top: 0;
z-index: 999999;
}
I use this menu module
https://www.opencart.com/index.php?rout ... ega%20menu
So I want to show the sticky menu
http://prntscr.com/m0mcxl
The theme http://www.spearthemes.com/oc-light/
Opencart 3.0.2.0
Now it just works like this
http://prntscr.com/m0mekz

If it can be done sticky menu with header
Thank you

Attachments

Sticky menu.jpg

Sticky menu.jpg (23.14 KiB) Viewed 795 times


Active Member

Posts

Joined
Wed Feb 14, 2018 1:47 am

Post by xxvirusxx » Fri Dec 28, 2018 10:42 pm

viewtopic.php?t=206927

LE: Install this extension (to edit ocmod files)
https://www.opencart.com/index.php?rout ... n_id=22318

And changes from converted ocmod (top link) and change <body class="{{ class }}"> to <body>

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by dani888 » Fri Dec 28, 2018 11:25 pm


Active Member

Posts

Joined
Wed Feb 14, 2018 1:47 am

Post by xxvirusxx » Fri Dec 28, 2018 11:36 pm

Because you don't have installed from Extensions->Modules....

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by dani888 » Sat Dec 29, 2018 2:36 am

I installed the module
But the module does not go with the fixed header menu

This javascript code works
viewtopic.php?t=203250
but you also need to add the top part
Maybe someone knows what to add to the javascript code to work with the header
Thank you

Active Member

Posts

Joined
Wed Feb 14, 2018 1:47 am

Post by xxvirusxx » Sat Dec 29, 2018 3:49 pm

Converted extension work just fine on that theme with default menu.
And because Mega Menu is a paid module that converted extension can't be tested

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by dani888 » Sat Dec 29, 2018 6:09 pm

Hello
Okay, it works
Thanks for your help

Active Member

Posts

Joined
Wed Feb 14, 2018 1:47 am

Post by dani888 » Sun Dec 30, 2018 1:58 am

Hello
Now it works with my menu
http://prntscr.com/m12e1d
I deleted a bracket and it does not work
Thanks for your help
Happy New Year

Active Member

Posts

Joined
Wed Feb 14, 2018 1:47 am
Who is online

Users browsing this forum: Semrush [Bot] and 13 guests