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

elem.ownerDocument is undefined when animate a not-dom object #87

Closed sovesove closed 12 years ago

sovesove commented 12 years ago

Got this error with touchcarousel plugin that do something like that:

var from = {property: 0}; var to = {property: 100};

jQuery(from).animate(to, { duration: 100, step: function() { console.log( 'Currently @ ' + this.property ); } });

the "from" element is not a dom element so the .css() method crash with the error elem.ownerDocument is undefined

nitriques commented 12 years ago

I think this bug is jQuery related.... jquery needs a DomElement for the animation.

Please see for animating non-Dom elements: http://acko.net/files/bacon/animation-demo.html

sovesove commented 12 years ago

Nope, jQuery give the possibility to "animate" also a property of a json object.

http://james.padolsey.com/javascript/fun-with-jquerys-animate/

nitriques commented 12 years ago

Hum can you give me the exact line where it fails ? I mean the like where the .css method is called in the plugin ? Try adding the parameter avoidCssTransitions for this particular case

sovesove commented 12 years ago

line 272 in function _interpretValue

nitriques commented 12 years ago

try this

jQuery(from).animate(to, { duration: 100, avoidCSSTransitions: true });

sovesove commented 12 years ago

yes, it works.

I had tried putting the parameter avoidCSSTransitions: true in the second object passed to the function. I suppose it would work so well, but moving it in the first object parameter make it works.

i moved avoidCSSTransitions: true from "params" json to "to" json. $(from).animate(to, params);

thank you.

nitriques commented 12 years ago

yes you need to put it in the first parameter passed to the animated functions, just as the others new params such as avoidTransforms, useTranslate3d, leaveTransforms.

You can close this issue since this plugin is for Dom-Element only.

sovesove commented 12 years ago

Close. Thank you.

nitriques commented 12 years ago

You are welcome. I am wroking on an new version for this plugin with a bunch of merge from others too. Check it out ! https://github.com/DeuxHuitHuit/jQuery-Animate-Enhanced/tree/