I have this piece of code (on jsfiddle)
var paper = new Raphael('holder', 400, 100);
var set = paper.set();
for(var i = 0; i < 10; i++) {
var circle = paper.circle((i * 30) + 30, 20, 5);
circle.attr({ fill: '#ff0' });
circle.animate(Raphael.animation({ transform: 's2,2' }, 2000).repeat('Infinity'));
set.push(circle);
}
set.hover(function() {
set.pause();
}, function() {
set.resume(); // <- things get nasty here
});
Now when the mouse enters the set, set.pause() is called correctly and all animations stop.
But when leaving the hover area it doesn’t resume the animation(s), instead I get following error in the console:
Uncaught TypeError: Cannot read property ‘transform’ of undefined
I have no idea why this happens; is anybody able to help?
On Safari/Firefox, after some time after hovering out, I received this error message (using the uncompressed source at https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael.js ):
The only place where
totalOriginis set is therunAnimationfunction:Your code calls first
elproto.pause()(line 3352), thenelproto.resume()(line 3361).pause()sets thepausedproperty to true,resume()deletes this property. Butresumealso calls thestatus()method right after deleting thepausedflag:The strange, work-in-progress
elproto.statusmethod (line 3323) is only called byelproto.setTime()andelproto.resume(). This function constructs some complex return value, but no active code uses its return value, only the commented out lines starting at line 2980.This function also calls the
runAnimationfunction, if it has avalueparameter:Unfortunately, it doesn’t pass anything for
totalOrigin, and this is the cause of the bug.I tried adding a
totalOriginparameter based on line 3312:While it seems to work, it goes buggy.
As a second attempt, I commented out the whole line:
Result: it works, but the timing is wrong, probably the animation start time should be updated somewhere.
http://jsfiddle.net/7nGcR/26/
https://raw.github.com/gist/3067995/1e82de48eeacf98697b572efdc74c11a9b1d9d03/gistfile1.js