javascript - jQuery: Need some help.. The callback function of .animate isn't working -


I have some kind of bounce effect in my animation plugin but it is not working. Callback is not called at all:

  $ (function () {var offset = $ ("# first") offset (); var status = $ (window) .scrollTop ($ (window) ) .scroll (function () {var scroll = $ (window) .scrollTop (); if (scroll> position) {$ ("body") .animate ({scrollTop: offset.top + $ (("Scrolltop : Offset.top - 150}, 1000, "easyOutBounce"}}) "" "" ""}})})  

OK .. this is my html code .. I do not know why your work is great .. but mine is not .. $ ('html') is not working but you're working fine ..

  & Lt; html lang = "en" Xmlns = "http://www.w3.org/1999/xhtml" xml: lang = "n"> gt; top & gt; & gt; title & gt; bounce test pad & lt; / title & gt; Gt; & lt; link rel = stylesheet href = "index.css" type = "text / css" /> gt; script type = "text / javascript" src = "jquery-1.3.2.js" Gt; & lt; / script & gt; & lt; script type = "text / javascript" src = "jquery.easing.1.3.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Img id = "lightbulb" src = "img / veioza.png" & gt; & Lt; Div id = "wrapper" & gt; & Lt; Img id = "first" class = "picture" src = "img / nike.jpg" /> & Lt; Img id = "second" class = "picture" src = "img / golden.jpg" /> & Lt; Img id = "third" square = "picture" src = "img / a.jpg" /> & Lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; $ (Window). Reset (function () {centerIt ();}); $ (Function () {centerIt ();}) function center this () {var viewportWidthSize = window.innerWidth; Var pixels = (ViewportWidths / 2) - $ ("#First"). Width () / 2; $ ("#include IMG"). CSS ("left", pixels); }; $ (Function () {var offset = $ ("# first") offset (); var prevpos = $ (window) .scrollTop (); var animating = false; $ (window) .scroll (function () {var Curpos = $ (Window) .scrollTop (); if (corp & gt; promos & amp; animating) {$ ('html'). Animate ({scrollTop: offset.top = $ ("# first"). }, 1000, "sleepinautquart")} animating = true;})}) & lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

About the animation that raises the Anchor scroll event is correct.

Here's a definite demo: (You can edit the demo here):

If the animation still occurs, then you have to add the code to prevent animating again:

  var status = $ ('# condition'); Var offset = $ ("# downcontent") Offset (); Var height = $ ("# downantant"). Height (); Var animating = false; Var prevpos = $ (window) .scrollTop (); $ (Window) .scroll (function () {var curpos = $ (window) .scrollTop (); if (curpos & gt; prevpos & amp;; animating) {$ ('html'). Animate ({scrollTop: offset (+ ScrollTop: offset.top), 1000, "easeOutBounce", function () {animating = false; status.html} ('Animation ended.');) Html ('first animation ended. & Lt; br / & gt; second animation started & lt; br / & gt;');}) ;; Animating = true; Status.html ('first animation started & lt; br / & gt;');} prevpos = curpos;});  

edit

Okay, I have created another demo with your HTML code. I have fixed javascript a bit and some CSS rules are added:


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -