Code working in editor preview but not on site on published site

I’m having trouble with my frozen menu. I’ve coded it so that my main menu shows when the page loads however on scrolling down, another menu shows up and the main menu disappears.

The issue I am having is that the code is working when i preview while in editor mode however when i save and view the published site the code doesn’t work. So it’s only working in editor preview. Has anyone had this encounter before?

The code is:

export function smallstrip_onviewportEnter(event, $w)
{
$w(“#smallstrip”).hide();
$w(“#menutext”).hide();
$w(“#largebutton”).hide();
$w(“#logo”).show();
$w(“#largestrip”).show();
$w(“#menu”).show();
$w(“#smallcontactbutton”).show();
}

export function largestrip_onviewportLeave(event, $w)
{
$w(“#smallstrip”).show();
$w(“#menutext”).show();
$w(“#largebutton”).show();
$w(“#logo”).hide();
$w(“#largestrip”).hide();
$w(“#menu”).hide();
$w(“#smallcontactbutton”).hide();
}

Like this one for example.
https://www.wix.com/corvid/forum/community-discussion/fixed-frozen-header-example

Yes like this. I’m having the same issue though when i changed my code to this one. It works in editor preview mode but not on the published site. Any ideas what I could be doing wrong?

@pekafisher

See Lior’s new post on his forum post about the header.

@givemeawhisky Thank you givemewhisky! My menu is working perfectly now :slight_smile: