Fixed bug with rapid mouse movement

This commit is contained in:
2022-01-30 12:08:44 +03:00
parent a0b30cafd3
commit 7e7335ef7c
3 changed files with 14 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ class MockupModel extends Group {
this.animation = this.floatAnim; this.animation = this.floatAnim;
this.goingHome = false; this.goingHome = false;
this.homeTimeout = null;
this.home = home; this.home = home;
this.reset(); this.reset();
@@ -55,7 +56,7 @@ class MockupModel extends Group {
this.rotSpeed.y = (this.home.rotation.y - this.rotation.y) / rT; this.rotSpeed.y = (this.home.rotation.y - this.rotation.y) / rT;
this.rotSpeed.z = (this.home.rotation.z - this.rotation.z) / rT; this.rotSpeed.z = (this.home.rotation.z - this.rotation.z) / rT;
setTimeout(() => { this.homeTimeout = setTimeout(() => {
this.goingHome = false; this.goingHome = false;
this.reset(); this.reset();
this.startFloat(); this.startFloat();
@@ -277,7 +278,11 @@ var script = {
} }
function handleMouseEnter() { function handleMouseEnter() {
if (phone) { phone.animation = phone.lookAtAnim; } if (phone) {
phone.animation = phone.lookAtAnim;
phone.goingHome = false;
clearTimeout(phone.homeTimeout);
}
} }
function handleMouseLeave() { function handleMouseLeave() {

View File

@@ -169,7 +169,11 @@ export default {
} }
function handleMouseEnter() { function handleMouseEnter() {
if (phone) { phone.animation = phone.lookAtAnim; } if (phone) {
phone.animation = phone.lookAtAnim;
phone.goingHome = false;
clearTimeout(phone.homeTimeout);
}
} }
function handleMouseLeave() { function handleMouseLeave() {

View File

@@ -6,6 +6,7 @@ export default class MockupModel extends Group {
this.animation = this.floatAnim; this.animation = this.floatAnim;
this.goingHome = false; this.goingHome = false;
this.homeTimeout = null;
this.home = home; this.home = home;
this.reset(); this.reset();
@@ -52,7 +53,7 @@ export default class MockupModel extends Group {
this.rotSpeed.y = (this.home.rotation.y - this.rotation.y) / rT; this.rotSpeed.y = (this.home.rotation.y - this.rotation.y) / rT;
this.rotSpeed.z = (this.home.rotation.z - this.rotation.z) / rT; this.rotSpeed.z = (this.home.rotation.z - this.rotation.z) / rT;
setTimeout(() => { this.homeTimeout = setTimeout(() => {
this.goingHome = false; this.goingHome = false;
this.reset(); this.reset();
this.startFloat(); this.startFloat();