zarocknz/javascript-winwheel

Once i Spin then I Again Need to Spin Same State no need reset wheel

Closed this issue · 2 comments

Once i spin the wheel then its sniping after display alert message i need to spin again without reset wheel its possible ?

Hi @mehuljariwala

Normally at least the winwheel.rotationAngle needs to be set back to 0 before spinning again if using the one of the built in animation types because the ending angle of the spin calculated as follows...

this.animation.propertyValue = (this.animation.spins * 360);

You don't need a reset link to do this. Sometimes people set winwheel.rotationAngle = 0 right before starting the animation. If the spinning is fast then users don't see its been reset, so that is one possible solution.

Another option is to increase the number of spins the animation has to do each time. For example first time if theWheel.animation.spins = 8 then second time make it 16, 32, etc as that will always make the ending angle of the spin greater than the current rotationAngle.

Yet another option might be to hack the Winwheel.js file and change this line (line 1950 in the computeAnimation() function)...

this.animation.propertyValue = (this.animation.spins * 360);

to

this.animation.propertyValue = this.rotationAngle + (this.animation.spins * 360);

This way the end angle for the spin in the animation will always be greater than the current rotationAngle of the wheel.

Regards,
DouG.

Hi @mehuljariwala

Normally at least the winwheel.rotationAngle needs to be set back to 0 before spinning again if using the one of the built in animation types because the ending angle of the spin calculated as follows...

this.animation.propertyValue = (this.animation.spins * 360);

You don't need a reset link to do this. Sometimes people set winwheel.rotationAngle = 0 right before starting the animation. If the spinning is fast then users don't see its been reset, so that is one possible solution.

Another option is to increase the number of spins the animation has to do each time. For example first time if theWheel.animation.spins = 8 then second time make it 16, 32, etc as that will always make the ending angle of the spin greater than the current rotationAngle.

Yet another option might be to hack the Winwheel.js file and change this line (line 1950 in the computeAnimation() function)...

this.animation.propertyValue = (this.animation.spins * 360);

to

this.animation.propertyValue = this.rotationAngle + (this.animation.spins * 360);

This way the end angle for the spin in the animation will always be greater than the current rotationAngle of the wheel.

Regards, DouG.

Hi, instead of resetting the spin before spinning again. Is it possible to reset the spin after the spinning? I tried resetting the spin in the callback like this "theWheel.rotationAngle = 0" but it doesn't work. It seems like the wheel will not visually reset if the animation hasn't been triggered. May I know is it possible to do this? Thanks in advance.