javascript-winwheel icon indicating copy to clipboard operation
javascript-winwheel copied to clipboard

Animation of more than one wheel does not work

Open zarocknz opened this issue 9 years ago • 0 comments

There is an issue with the way the current animation loop is implemented where if there is more than one wheel on the page, starting the animation of the second wheel kills the animation of the first.

Need to allow a way for multiple wheels on the same canvas to be animated, and also preferably all wheels on any canvases on the screen.

Think the issue at the moment is just that there is a single variable on the page called winwheelToDrawDuring animation and this needs to change to an array of wheel objects.

The winwheelAnimationLoop() function then needs to loop though the array of wheels to draw and call the draw method in them along with any animation before and after callbacks for the wheel.

Might also need to change the way the winwheelAnimationLoop() function is added to the GreenSock ticker; have this happen outside any particular wheel. This might mean that the ticker is always running and the wheels always updating even when not animated. This could be a good or a bad thing. Might be able to add parameter to the wheel to keep track of the animation state and only re-draw the wheels when animating.

Also look to have at adding all wheels to the array of wheels to draw automatically at time of creation, rather than when animation start is called - unless use this array to add and remove wheels to be animated - i.e. add on animation start, remove on animation end - that might solve the issue above of not wanting to re-draw static wheels.

If this is all sorted also create a "Multiwheel" example for the examples folder and look to create tutorial for this on the site. Check existing animation tutorials too in case they need to be updated.

zarocknz avatar Apr 04 '16 08:04 zarocknz