I am trying to animate my mouseY and mouseX values to zero (over the course of .5 seconds) whenever the mouse exits a specific container.
Here is my code.
function ondocumentMouseLeave ( event ){
var intersects = ondocumentMouseLeave (true)
new TWEEN.Tween( intersects[ 0 ].mouseY ).to( {
x: 0 }, 500 )
.easing( TWEEN.Easing.Elastic.Out).start();
new TWEEN.Tween( intersects[ 0 ].mouseX ).to( {
x: 0}, 500)
.easing( TWEEN.Easing.Elastic.Out).start();
}
I know this is recursive but how do I just get the animation to start when the mouse leaves?
I apologize if this is a simple question.. but I am quite new to this.
edit:
I tried this:
function ondocumentMouseLeave ( event ){
event.preventDefault();
new TWEEN.Tween( mouseY ).to( {
y: 0 }, 500 )
.easing( TWEEN.Easing.Linear.None).start();
new TWEEN.Tween( mouseX ).to( {
x: 0}, 500)
.easing( TWEEN.Easing.Linear.None).start();
But it gave me this error
"Uncaught TypeError: Cannot create property 'y' on number '-56'"
Does that mean it is conflicting with another function that is currently setting mouseX and Y?
Because if I write this:
function ondocumentMouseLeave ( event ){
mouseX = 0
mouseY = 0
}
it functions and does NOT give me an error, but it also does not animate to these values.
What am I doing wrong?