Reputation: 241
Here is the link: JSFIDDLE
$('.main-menu').addClass('fixed');
How come the fixed element is flickering whenever the fixed class is added?
Upvotes: 1
Views: 73
Reputation: 2597
You're constantly removing and re-adding the fixed
CSS attribute because everytime you scroll, the top offset changes. What you want to do is store it in a variable on load, then compare against that variable.
JSFiddle: http://jsfiddle.net/j44xdv3m/6/
Upvotes: 3