Friday 15 August 2014

javascript - jQuery: Something is delaying animations -


What does the animation delay? All types of jQuery are being delayed on the site.

  $ (function () {$ (window) .scroll (function () {var elementTop = $ ('body') Offset (.) Top; var position = elementTop + $ (window) .scrollTop (); if (position> = 20) {$ ('# top'). Animate ({top: '40px'}, 300 );} Otherwise if (position & lt; 20) {$ ('# top'). Animate ({top: '80px'}, 300);} console.log (status);});});   

Live: - This is Menu / Navigation

Your code is being removed every time you scroll, Chetan methods are being collected, one after the other moves to get what you want, you get the current animation Must stop and start a new one:

  $ (function () {$ (window) .scroll (function () {var elementTop = $ ('body'). Offset (). Top, position = element: + $ (window) .scrollTop (); Animate ({top: '40px'}, 300);} and if (condition <20) {$ ('#'), if (position & gt; = 20) {$ ('# top'). Top '). Stop (). Animate ({top:' 80px '}, 300);}});});    

No comments:

Post a Comment