[gnome-shell] iconGrid: Remove clones on new animation



commit 96a49770a43358458d55405718756b1f6e948d20
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Fri Sep 5 19:33:37 2014 +0200

    iconGrid: Remove clones on new animation
    
    Until now we were waiting the animation to complete to allow the user to
    make a new animation. This could bring some problems and annoy nervous
    users.
    Instead of that, destroy clones on new animations triggers and
    create a new animation with the new direction.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736148

 js/ui/iconGrid.js |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index b7af365..bd3c453 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -267,6 +267,7 @@ var IconGrid = new Lang.Class({
         this.actor = new St.BoxLayout({ style_class: 'icon-grid',
                                         vertical: true });
         this._items = [];
+        this._clonesAnimating = [];
         // Pulled from CSS, but hardcode some defaults here
         this._spacing = 0;
         this._hItemSize = this._vItemSize = ICON_SIZE;
@@ -410,8 +411,13 @@ var IconGrid = new Lang.Class({
         return this._getVisibleChildren();
     },
 
+    _cancelAnimation: function() {
+        this._clonesAnimating.forEach(clone => { clone.destroy(); });
+        this._clonesAnimating = [];
+    },
+
     _animationDone: function() {
-        this._animating = false;
+        this._clonesAnimating = [];
         this.emit('animation-done');
     },
 
@@ -419,10 +425,7 @@ var IconGrid = new Lang.Class({
         if (animationDirection != AnimationDirection.IN)
             throw new Error("Pulse animation only implements 'in' animation direction");
 
-        if (this._animating)
-            return;
-
-        this._animating = true;
+        this._cancelAnimation();
 
         let actors = this._getChildrenToAnimate();
         if (actors.length == 0) {
@@ -470,10 +473,7 @@ var IconGrid = new Lang.Class({
     },
 
     animateSpring: function(animationDirection, sourceActor) {
-        if (this._animating)
-            return;
-
-        this._animating = true;
+        this._cancelAnimation();
 
         let actors = this._getChildrenToAnimate();
         if (actors.length == 0) {
@@ -507,6 +507,7 @@ var IconGrid = new Lang.Class({
             actor.reactive = false;
 
             let actorClone = new Clutter.Clone({ source: actor });
+            this._clonesAnimating.push(actorClone);
             Main.uiGroup.add_actor(actorClone);
 
             let [width, height,,] = this._getAllocatedChildSizeAndSpacing(actor);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]