benbarnett / jquery-animate-enhanced

Extend $.animate() to detect CSS transitions for Webkit, Mozilla, IE>=10 and Opera and convert animations automatically.
http://playground.benbarnett.net/jquery-animate-enhanced/
MIT License
1.38k stars 197 forks source link

animating right prop from negative to 0 not properly handle #131

Open jjmaceda opened 11 years ago

jjmaceda commented 11 years ago

if I try to animate

$('.mobile-menu').animate({ right: 0 },

when .mobile-menu has right -200px, the return value for the transition is 200 instead of 0, I track the issue to the private method _applyCSSTransition under

offsetPosition = value - cleanPropertyValue;

value = 0 and cleanPropertyValue = -200 so the offsetPosition give me 200

in needs something else to handle the values correctly thanks!

hitchhiker commented 11 years ago

Same problem animating from NEGATIVE on 'bottom'.

hitchhiker commented 11 years ago

In _function applyCSSTransition(e, property, duration, ... i changed:

offsetPosition = value - cleanPropertyValue;

To:

            if (property=='bottom' || property=='right')
                offsetPosition = value;
            else
                offsetPosition = value - cleanPropertyValue;

Horrible hack, untested, didn't investigate anything properly - just needed a solution. BEWARE!

Kravimir commented 10 years ago

Thanks for posting that fix, hitchhiker. It makes the "right" property animate as expected.

I've run into this problem on multiple projects now. Ben, would you please fix this?

In case anyone would like to know, to apply hitchhiker's fix to the current minified version, you change s=f-p; to s=(b=='bottom'||b=='right')?f:(f-p);

isayeter commented 8 years ago

thanks ! this works for "bottom" too !