TJ Sherrill TJ Sherrill - 1 year ago 67
Javascript Question

How to run an .animate immediately after fancybox function

I am trying to open a

then run an animation on a z-indexed item. I want the .animate function to run automatically after the
has opened.

to open a fancybox:

What I need to do is

$("#box").animate({left: "200"}, slow)

But this clearly won't work. I am still learning jquery and js...

Answer Source

Fancybox has an onComplete callback.

var box = $("#box")
  'onComplete': function() { box.animate({left: "200"}, slow); }