My preview is different then my publish site

It isn’t leave and enter, you need to use onViewport.
https://www.wix.com/corvid/reference/$w.ViewportMixin.html

See here for a Wix Corvid Tutorial.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/fixed-frozen-header-example