Copy link to clipboard
Copied
Hello I need very simple function but can`t find any info for it:
i need on mouse scroll down / up to start function where animations load - is that possible?
Thanks
You can try something like this:
function onMouseWheel(e)
{
if (this.anim.currentFrame == 0)
this.anim.play();
}
document.getElementById('canvas').addEventListener('mousewheel', onMouseWheel.bind(this));
document.getElementById('canvas').addEventListener('DOMMouseScroll', onMouseWheel.bind(this));
Regards,
JC
Copy link to clipboard
Copied
Hi.
AS3 or HTML5?
And do you need the animation to keep playing while the mouse wheel is being rotated or do you need the animation to only play once?
Regards,
JC
Copy link to clipboard
Copied
Hello, HTML5 , I need just one to be started. Both scroll down and up
Copy link to clipboard
Copied
You can try something like this:
function onMouseWheel(e)
{
if (this.anim.currentFrame == 0)
this.anim.play();
}
document.getElementById('canvas').addEventListener('mousewheel', onMouseWheel.bind(this));
document.getElementById('canvas').addEventListener('DOMMouseScroll', onMouseWheel.bind(this));
Regards,
JC
Copy link to clipboard
Copied
WOW! thanks a lot. is there a way to define if "scroll down" or "scroll up" ?
Copy link to clipboard
Copied
Sure.
Try this:
function onMouseWheel(e)
{
var delta;
// we have to check what kind of property is available depending on the browser the page is running
if (e == window.event)
delta = -10 / window.event.wheelDeltaY;
else
delta = e.detail / 30;
if (delta < 0)
{
if (this.anim.currentFrame == 0)
this.anim.play();
}
else
{
if (this.anim1.currentFrame == 0)
this.anim1.play();
}
}
document.getElementById('canvas').addEventListener('mousewheel', onMouseWheel.bind(this));
document.getElementById('canvas').addEventListener('DOMMouseScroll', onMouseWheel.bind(this));
Regards,
JC
Copy link to clipboard
Copied
Thanks a lot mate - that works great!
Copy link to clipboard
Copied
You're welcome!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now