add tween update callback

This commit is contained in:
2025-07-19 07:52:41 -05:00
parent 7fb0d9e80a
commit bb3c2c34d0

View File

@@ -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) {