javascript - Scroll function does not fire an animation properly -


मेरे पास कोई साधारण .scroll () फ़ंक्शन एक ईवेंट आग है, अगर .scrollTop () एक विशिष्ट मूल्य से अधिक है:

  $ (window) .scroll (function () {if ($ ('body, html') .scrollTop () & gt; 250) {console.log ("high"); $ ('# navbar')। एनिमेट ({पैडिंगटॉप: 5, पैडिंगबॉटम: 5}, 'धीमी');} else {console.log ( "कम"); $ ('# navbar')। चेतन ({पैडिंगटॉप: 25, पैडिंगबॉटम: 25}, 'धीमी')}}});  

मेरे पास समस्या है, यह प्रत्येक स्क्रॉल पिक्सेल के लिए फ़ंक्शन को निकालती है scrollTop मान के आधार पर मैं एनीमेशन को आग्रह करना चाहता हूं।

मैं इसे कैसे सबसे अच्छा तरीका हल कर सकता हूं?

धन्यवाद

यह कोशिश करें

  var _top, _last_top = -1; $ (विंडो) .scroll (function () {_top = $ ('body, html')। ScrollTop (); अगर (_top & gt; 250 & amp; _last_top & lt; 250) {_last_top = _top; $ ('# एमीमेट ({पैडिंगटॉप: 5, पैडिंगबॉटम: 5}, 'धीमी');} अगर (_top और lt; 250 & amp; amp; _last_top & gt; 250) {_last_top = _top; $ ('# navbar')। चेतन ({पैडिंगटॉप: 25, पैडिंगबॉटम: 25}, 'धीमी');}});  

Comments

Popular posts from this blog

Active Directory Authenticated Proxy Server with Squid or CNTLM -

java - @PluginTarget(Node.class) not registering as neo4j plugin -

python - Calculate STD manually using Groupby Pandas DataFrame -