laya-coreui-es
Version:
laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改
40 lines (39 loc) • 1.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ButtonEffect = void 0;
const Tween_1 = require("../utils/Tween");
const Event_1 = require("../events/Event");
const Ease_1 = require("../utils/Ease");
const Handler_1 = require("../utils/Handler");
class ButtonEffect {
constructor() {
this._curState = 0;
this.effectScale = 1.5;
this.tweenTime = 300;
}
set target(tar) {
this._tar = tar;
tar.on(Event_1.Event.MOUSE_DOWN, this, this.toChangedState);
tar.on(Event_1.Event.MOUSE_UP, this, this.toInitState);
tar.on(Event_1.Event.MOUSE_OUT, this, this.toInitState);
}
toChangedState() {
this._curState = 1;
if (this._curTween)
Tween_1.Tween.clear(this._curTween);
this._curTween = Tween_1.Tween.to(this._tar, { scaleX: this.effectScale, scaleY: this.effectScale }, this.tweenTime, Ease_1.Ease[this.effectEase], Handler_1.Handler.create(this, this.tweenComplete));
}
toInitState() {
if (this._curState == 2)
return;
if (this._curTween)
Tween_1.Tween.clear(this._curTween);
this._curState = 2;
this._curTween = Tween_1.Tween.to(this._tar, { scaleX: 1, scaleY: 1 }, this.tweenTime, Ease_1.Ease[this.backEase], Handler_1.Handler.create(this, this.tweenComplete));
}
tweenComplete() {
this._curState = 0;
this._curTween = null;
}
}
exports.ButtonEffect = ButtonEffect;