[gnome-maps] Add linear goto mode



commit a7e2fd6e0476f5695845b550ce0ee56757dd70ef
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Wed Nov 18 20:20:36 2015 +0100

    Add linear goto mode

 src/mapView.js   |    6 +++---
 src/mapWalker.js |   41 +++++++++++++++++++++++++----------------
 2 files changed, 28 insertions(+), 19 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 96ba0d9..a0a08c1 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -284,10 +284,10 @@ const MapView = new Lang.Class({
                                                        bottom: box[1],
                                                        left: box[2],
                                                        right: box[3] });
-        this._gotoBBox(bounding_box);
+        this._gotoBBox(bounding_box, true);
     },
 
-    _gotoBBox: function(bbox) {
+    _gotoBBox: function(bbox, linear) {
         let [lat, lon] = bbox.get_center();
         let place = new Place.Place({
             location: new Location.Location({ latitude  : lat,
@@ -297,7 +297,7 @@ const MapView = new Lang.Class({
                                                     left   : bbox.left,
                                                     right  : bbox.right })
         });
-        new MapWalker.MapWalker(place, this).goTo(true);
+        new MapWalker.MapWalker(place, this).goTo(true, true);
     },
 
     showTurnPoint: function(turnPoint) {
diff --git a/src/mapWalker.js b/src/mapWalker.js
index 9fa51bd..692c81e 100644
--- a/src/mapWalker.js
+++ b/src/mapWalker.js
@@ -87,7 +87,7 @@ const MapWalker = new Lang.Class({
         }
     },
 
-    goTo: function(animate) {
+    goTo: function(animate, linear) {
         Utils.debug('Going to ' + this.place.name);
         this._mapView.emit('going-to');
 
@@ -98,32 +98,41 @@ const MapWalker = new Lang.Class({
             return;
         }
 
-        /* Lets first ensure that both current and destination location are visible
+        let fromLocation = new Location.Location({ latitude: this._view.get_center_latitude(),
+                                                   longitude: this._view.get_center_longitude() });
+        this._updateGoToDuration(fromLocation);
+
+        if (linear) {
+            this._view.goto_animation_mode = Clutter.AnimationMode.LINEAR;
+            Utils.once(this._view, 'animation-completed',
+                       this.zoomToFit.bind(this));
+            this._view.go_to(this.place.location.latitude,
+                             this.place.location.longitude);
+        } else {
+            /* Lets first ensure that both current and destination location are visible
          * before we start the animated journey towards destination itself. We do this
          * to create the zoom-out-then-zoom-in effect that many map implementations
          * do. This not only makes the go-to animation look a lot better visually but
          * also give user a good idea of where the destination is compared to current
          * location.
          */
-
         this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_CUBIC;
 
-        let fromLocation = new Location.Location({ latitude: this._view.get_center_latitude(),
-                                                   longitude: this._view.get_center_longitude() });
-        this._updateGoToDuration(fromLocation);
 
-        Utils.once(this._view, 'animation-completed', (function() {
-            Utils.once(this._view, 'animation-completed::go-to', (function() {
-                this.zoomToFit();
-                this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
-                this.emit('gone-to');
-            }).bind(this));
+            Utils.once(this._view, 'animation-completed', (function() {
+                Utils.once(this._view, 'animation-completed::go-to', (function() {
+                    this.zoomToFit();
+                    this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
+                    this.emit('gone-to');
+                }).bind(this));
 
-            this._view.goto_animation_mode = Clutter.AnimationMode.EASE_OUT_CUBIC;
-            this._view.go_to(this.place.location.latitude, this.place.location.longitude);
-        }).bind(this));
+                this._view.goto_animation_mode = Clutter.AnimationMode.EASE_OUT_CUBIC;
+                this._view.go_to(this.place.location.latitude,
+                                 this.place.location.longitude);
+            }).bind(this));
 
-        this._ensureVisible(fromLocation);
+            this._ensureVisible(fromLocation);
+        }
     },
 
     _ensureVisible: function(fromLocation) {


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