[gnome-shell/wip/swarm: 21/30] viewSelector: Allow different animation types



commit d146041d89951858694e182ca831a1ff70a23922
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Tue Jun 17 19:10:54 2014 +0200

    viewSelector: Allow different animation types

 js/ui/viewSelector.js |   59 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 19 deletions(-)
---
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 5a0ed09..60d35ad 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -206,18 +206,41 @@ const ViewSelector = new Lang.Class({
         return page;
     },
 
-    _fadePageIn: function(oldPage) {
-        if (oldPage)
-            oldPage.hide();
+    _fadePageIn: function(page) {
+        Tweener.addTween(page,
+                         { opacity: 255,
+                           time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
+                           transition: 'easeOutQuad'
+                         });
+    },
 
-        this.emit('page-empty');
+    _fadePageOut: function(page, onComplete) {
+        Tweener.addTween(page,
+                         { opacity: 0,
+                           time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
+                           transition: 'easeOutQuad',
+                           onComplete: Lang.bind(this,
+                               function() {
+                                    if (onComplete)
+                                        onComplete();
+                               })
+                         });
+    },
 
+    _animateIn: function(page) {
         this._activePage.show();
-        Tweener.addTween(this._activePage,
-            { opacity: 255,
-              time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
-              transition: 'easeOutQuad'
-            });
+
+        this._fadePageIn(this._activePage);
+    },
+
+    _animateOut: function(page, onComplete) {
+        this._fadePageOut(page, onComplete);
+    },
+
+    _hidePageAndSyncEmpty: function(page) {
+        if (page)
+            page.hide();
+        this.emit('page-empty');
     },
 
     _showPage: function(page, animateOut) {
@@ -228,18 +251,16 @@ const ViewSelector = new Lang.Class({
         this._activePage = page;
         this.emit('page-changed');
 
+        let animateActivePage = Lang.bind(this,
+            function() {
+                this._hidePageAndSyncEmpty(oldPage);
+                this._animateIn(this._activePage);
+            });
+
         if (oldPage && animateOut)
-            Tweener.addTween(oldPage,
-                             { opacity: 0,
-                               time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
-                               transition: 'easeOutQuad',
-                               onComplete: Lang.bind(this,
-                                   function() {
-                                       this._fadePageIn(oldPage);
-                                   })
-                             });
+            this._animateOut(oldPage, animateActivePage)
         else
-            this._fadePageIn(oldPage);
+            animateActivePage();
     },
 
     _a11yFocusPage: function(page) {


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