Skip to content

Commit 2b788cd

Browse files
committed
fix: Fixed error when registered tweens are not completed in order
1 parent 1aee99e commit 2b788cd

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

dist/tween.amd.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ define(['exports'], (function (exports) { 'use strict';
303303
tween.onComplete(function () {
304304
prevCallback === null || prevCallback === void 0 ? void 0 : prevCallback(tween);
305305
// Since _isPlaying is updated to false after the onComplete callback finishes, the final tween is omitted from the check to determine if all animations have completed
306-
if (group.slice(0, group.length - 1).every(function (t) { return !t.isPlaying(); }))
306+
var completedGroup = group.filter(function (tween) { return !tween.isPlaying(); });
307+
if (completedGroup.length === group.length - 1)
307308
callback(group);
308309
});
309310
});

dist/tween.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ var Group = /** @class */ (function () {
305305
tween.onComplete(function () {
306306
prevCallback === null || prevCallback === void 0 ? void 0 : prevCallback(tween);
307307
// Since _isPlaying is updated to false after the onComplete callback finishes, the final tween is omitted from the check to determine if all animations have completed
308-
if (group.slice(0, group.length - 1).every(function (t) { return !t.isPlaying(); }))
308+
var completedGroup = group.filter(function (tween) { return !tween.isPlaying(); });
309+
if (completedGroup.length === group.length - 1)
309310
callback(group);
310311
});
311312
});

dist/tween.esm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ var Group = /** @class */ (function () {
301301
tween.onComplete(function () {
302302
prevCallback === null || prevCallback === void 0 ? void 0 : prevCallback(tween);
303303
// Since _isPlaying is updated to false after the onComplete callback finishes, the final tween is omitted from the check to determine if all animations have completed
304-
if (group.slice(0, group.length - 1).every(function (t) { return !t.isPlaying(); }))
304+
var completedGroup = group.filter(function (tween) { return !tween.isPlaying(); });
305+
if (completedGroup.length === group.length - 1)
305306
callback(group);
306307
});
307308
});

dist/tween.umd.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@
307307
tween.onComplete(function () {
308308
prevCallback === null || prevCallback === void 0 ? void 0 : prevCallback(tween);
309309
// Since _isPlaying is updated to false after the onComplete callback finishes, the final tween is omitted from the check to determine if all animations have completed
310-
if (group.slice(0, group.length - 1).every(function (t) { return !t.isPlaying(); }))
310+
var completedGroup = group.filter(function (tween) { return !tween.isPlaying(); });
311+
if (completedGroup.length === group.length - 1)
311312
callback(group);
312313
});
313314
});

src/Group.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ export default class Group {
9090
const prevCallback = tween.getCompleteCallback()
9191
tween.onComplete(() => {
9292
prevCallback?.(tween)
93-
// Since _isPlaying is updated to false after the onComplete callback finishes, the final tween is omitted from the check to determine if all animations have completed
94-
if (group.slice(0, group.length - 1).every(t => !t.isPlaying())) callback(group)
93+
// After the onComplete callback completes, _isPlaying is updated to false, so if the total number of completed tweens is -1, then they are all complete.
94+
const completedGroup = group.filter(tween => !tween.isPlaying())
95+
if (completedGroup.length === group.length - 1) callback(group)
9596
})
9697
})
9798
}

0 commit comments

Comments
 (0)