add tween update callback
This commit is contained in:
@@ -53,6 +53,11 @@ Tween.prototype.onComplete = function(callback) {
|
||||
return this
|
||||
}
|
||||
|
||||
Tween.prototype.onUpdate = function(cb) {
|
||||
this.onUpdateCallback = cb
|
||||
return this
|
||||
}
|
||||
|
||||
Tween.prototype._update = function(now) {
|
||||
var elapsed = now - this.startTime
|
||||
var t = Math.min(elapsed / this.duration, 1)
|
||||
@@ -62,6 +67,7 @@ Tween.prototype._update = function(now) {
|
||||
var start = this.startVals[key]
|
||||
var end = this.endVals[key]
|
||||
this.obj[key] = start + (end - start) * eased
|
||||
this.onUpdateCallback?.()
|
||||
}
|
||||
|
||||
if (t == 1) {
|
||||
|
||||
Reference in New Issue
Block a user