淹没分析
This commit is contained in:
@ -9,7 +9,7 @@ class Submerge extends Tools {
|
||||
* @param sdk
|
||||
* @description 淹没效果
|
||||
* */
|
||||
constructor(sdk, options = {}, _Dialog = {}) {
|
||||
constructor(sdk, options = {}, _Dialog = {}, callback) {
|
||||
super(sdk, options);
|
||||
this.sdk = sdk
|
||||
this.options = {}
|
||||
@ -27,6 +27,7 @@ class Submerge extends Tools {
|
||||
this.area = 0
|
||||
this._elms = {};
|
||||
this.tools = new Tools(this.sdk)
|
||||
this.callback = callback
|
||||
YJ.Analysis.AnalysesResults.push(this)
|
||||
// Submerge.EditBox(this)
|
||||
// Submerge.create(this)
|
||||
@ -276,6 +277,7 @@ class Submerge extends Tools {
|
||||
value = 0
|
||||
}
|
||||
that.options.waterVolume = Math.floor(value * 10000) / 10000;
|
||||
|
||||
if (that.area) {
|
||||
that.waterLevel = Number((that.options.waterVolume / that.area).toFixed(4))
|
||||
that.options.maxWaterLevel = that.options.minWaterLevel + that.waterLevel
|
||||
@ -338,7 +340,6 @@ class Submerge extends Tools {
|
||||
}
|
||||
set onEnd(val) {
|
||||
if (val && typeof val !== 'function') {
|
||||
console.error('val:', val, '不是一个function')
|
||||
} else {
|
||||
this.clickCallBack = val
|
||||
}
|
||||
@ -387,11 +388,17 @@ class Submerge extends Tools {
|
||||
// if (this.TweenAnimate) {
|
||||
// TWEEN.remove(this.TweenAnimate)
|
||||
// }
|
||||
if (!this.TweenAnimate) {
|
||||
let that = this
|
||||
if (!this.TweenAnimate && this.options.risingSpeed) {
|
||||
let totalTime = ((this.options.maxWaterLevel - this.options.minWaterLevel) / this.options.risingSpeed) * 1000
|
||||
this.TweenAnimate = new TWEEN.Tween({ waterLevel: this.options.minWaterLevel }).to({ waterLevel: this.options.maxWaterLevel }, totalTime).delay(this.delay).easing(TWEEN.Easing.Linear.None).onUpdate(async (r, a) => {
|
||||
this.currentWaterLaver = r.waterLevel
|
||||
}).onComplete(() => {
|
||||
that.callback()
|
||||
// 在这里执行动画结束后的逻辑
|
||||
}).start()
|
||||
} else if (!this.options.risingSpeed) {
|
||||
that.callback()
|
||||
}
|
||||
// let contentElm = this._DialogObject._element.body
|
||||
// let pauseBtn = contentElm.getElementsByClassName('pause')[0];
|
||||
@ -403,6 +410,7 @@ class Submerge extends Tools {
|
||||
restart() {
|
||||
this.currentWaterLaver = this.options.minWaterLevel
|
||||
let isPaused = false
|
||||
let that = this
|
||||
if (this.TweenAnimate) {
|
||||
isPaused = this.TweenAnimate._isPaused
|
||||
TWEEN.remove(this.TweenAnimate)
|
||||
@ -410,6 +418,9 @@ class Submerge extends Tools {
|
||||
let totalTime = ((this.options.maxWaterLevel - this.options.minWaterLevel) / this.options.risingSpeed) * 1000
|
||||
this.TweenAnimate = new TWEEN.Tween({ waterLevel: this.options.minWaterLevel }).to({ waterLevel: this.options.maxWaterLevel }, totalTime).delay(this.delay).easing(TWEEN.Easing.Linear.None).onUpdate(async (r, a) => {
|
||||
this.currentWaterLaver = r.waterLevel
|
||||
}).onComplete(() => {
|
||||
that.callback()
|
||||
// 在这里执行动画结束后的逻辑
|
||||
}).start()
|
||||
// if (isPaused) {
|
||||
this.pause()
|
||||
|
||||
Reference in New Issue
Block a user