2014. augusztus 5., kedd

Proper way to animate with JavaScript


Hi there,


I would like a little advice for a proper way to animate with JavaScript, without using jQuery animate or Tweenlite. For example, i would like to do a basic addClass/removeClass on elements when an animation is finished. Let's say that the animation duration is 300ms. I would write it that way :



element.addClass('hidden'); setTimeout(function () { otherElement.removeClass('visible'): }, 300);

However, it seems to me that this method is not the best, because whenever you have complex animation, you'll have to chain setTimeout inside other setTimeout, which is really ugly code.


Would appreciate your help !


Best regards,






Nincsenek megjegyzések:

Megjegyzés küldése