Mehdi
Mehdi

Reputation: 85

Stop canvas animation on mouse out

I am trying to make an interactive banner of rounded rectangles. Those rectangles are animated on mouse over and I want the animation to stop on mouse out. The problem is the animation doesn't stop on mouse out...

You can check (and criticize) my code right here: http://jsbin.com/osevaz/edit#source

Thank you all in advance,

Mehdi

Upvotes: 1

Views: 674

Answers (1)

kirilloid
kirilloid

Reputation: 14304

You do not return timerId in animate function

=> anim is undefined

=> cancelRequestAnimFrame doesn't stop animation

Moreover, Firefox (5-8) has mozRequestAnimationFrame, but no mozCancelRequestAnimationFrame

Read more about that and cross-browser animation.

Upvotes: 1

Related Questions