user3808357
user3808357

Reputation: 241

Sticky Navigation Menu

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

Answers (1)

Ford
Ford

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

Related Questions