Skip to content

Commit

Permalink
Do not animate disposed icons (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhendric authored Mar 21, 2021
1 parent b23b948 commit a081e41
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions docking.js
Original file line number Diff line number Diff line change
Expand Up @@ -2017,14 +2017,21 @@ var IconAnimator = class DashToDock_IconAnimator {
const danceRotation = progress < 1/6 ? 15*Math.sin(progress*24*Math.PI) : 0;
const dancers = this._animations.dance;
for (let i = 0, iMax = dancers.length; i < iMax; i++) {
dancers[i].rotation_angle_z = danceRotation;
dancers[i].target.rotation_angle_z = danceRotation;
}
});
}

destroy() {
this._timeline.stop();
this._timeline = null;
for (const name in this._animations) {
const pairs = this._animations[name];
for (let i = 0, iMax = pairs.length; i < iMax; i++) {
const pair = pairs[i];
pair.target.disconnect(pair.targetDestroyId);
}
}
this._animations = null;
}

Expand All @@ -2043,20 +2050,26 @@ var IconAnimator = class DashToDock_IconAnimator {
}

addAnimation(target, name) {
this._animations[name].push(target);
const targetDestroyId = target.connect('destroy', () => this.removeAnimation(target, name));
this._animations[name].push({ target, targetDestroyId });
if (this._started && this._count === 0) {
this._timeline.start();
}
this._count++;
}

removeAnimation(target, name) {
const index = this._animations[name].indexOf(target);
if (index >= 0) {
this._animations[name].splice(index, 1);
this._count--;
if (this._started && this._count === 0) {
this._timeline.stop();
const pairs = this._animations[name];
for (let i = 0, iMax = pairs.length; i < iMax; i++) {
const pair = pairs[i];
if (pair.target === target) {
target.disconnect(pair.targetDestroyId);
pairs.splice(i, 1);
this._count--;
if (this._started && this._count === 0) {
this._timeline.stop();
}
return;
}
}
}
Expand Down

0 comments on commit a081e41

Please sign in to comment.