Refactor mouth open time calculation and conditional logic in animeCat.js
This commit is contained in:
12
animeCat.js
12
animeCat.js
@@ -213,15 +213,17 @@ _bindMouseHold() {
|
|||||||
mouseDown = false;
|
mouseDown = false;
|
||||||
reopenEyes();
|
reopenEyes();
|
||||||
const heldFor = Date.now() - mouseDownAt;
|
const heldFor = Date.now() - mouseDownAt;
|
||||||
const mouthOpenTime = Math.max(heldFor - 1000, 700);
|
if (heldFor > 1000) {
|
||||||
if (mouthOpenTime > 0) {
|
// mind. 500ms oder (heldFor - 1000), je nachdem was größer ist
|
||||||
|
const mouthOpenTime = Math.max(heldFor - 1000, 500);
|
||||||
this.img.src = this.images.mouthOpen || this.images.default;
|
this.img.src = this.images.mouthOpen || this.images.default;
|
||||||
this._startBlinking();
|
this._startBlinking();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!joyActive && !this._isSpeaking && !this._pettingActive) this.img.src = this.images.default;
|
if (!joyActive && !this._isSpeaking && !this._pettingActive) {
|
||||||
|
this.img.src = this.images.default;
|
||||||
|
}
|
||||||
}, mouthOpenTime);
|
}, mouthOpenTime);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this._startBlinking();
|
this._startBlinking();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user