Sorry if this is an easy one, I’m new to jQuery. I am using the Flip! plugin to rotate a div in place. I would also like to move the div while it is rotating. Currently I am doing this:
$("#flipDiv").flip({
direction:'lr',
content:newContent
});
$("#flipDiv").animate({
'marginLeft' : "+=150px"
});
It does flip the div, but the animation does not run until the flipping is done, and even then it goes all at once. Since I am not very familiar with javascript, I do not know if this is a limitation of the language, or of this particular plugin, or if I am just doing it wrong. Does anyone know of a better way something like this can be done?
I’m assuming that
flipmust just be usinganimateunder the covers, which by default allows you to queue up multiple animations which then play out in order. To avoid this you can tell an given animation to not queue itself and execute immediately.So try this:
For more information have a look at the API documentation on
animate, as well asqueueanddequeue.Edit: Ok, looking at the source of the flip plugin I now believe the problem is that when you run
flipit actually hides the element (#flipDivin your case), creates a placeholder clone that it does its flip animation on & then re-shows the original div in its final state. This means that even if you make the animation happen at the same time, it will be animating the hidden div, so it will suddenly reappear either half way through the animation or after it has finished.You could try instead to animate the clone, which you can access from the
onBeforecallback like so:Of course that won’t actually move the original div, so when the flip finishes your div will still be in the old location, so you’ll need to shift that too. If you expect the animate to take the same (or less) time as the flip then you could just set the original’s marginLeft directly, otherwise you could animate it too so it stays roughly in sync.