summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Danielsson <jonas@threetimestwo.org>2014-01-15 14:09:47 +0100
committerJonas Danielsson <jonas@threetimestwo.org>2014-01-22 22:00:32 +0100
commit54ec97ba8d5c3e8e77c308b3f7be5e4f44008f71 (patch)
treeaf8d6b123c8f3dcf297c0284b8e5d886d86036db
parent316a87f9998e68e7ed92eb765408de82a8e42267 (diff)
downloadgnome-maps-54ec97ba8d5c3e8e77c308b3f7be5e4f44008f71.tar.gz
mapLocation: set saner goto animation duration
Champlain calculates the goto_animation_duration using zoom_level. It also treats ensure_visible as a go_to with its own duration time. In Maps, each goTo is a combination of a call to Champlain's ensure_visible and go_to. This patch calculates the goto animation duration using the distance between the two locations. It also divides the calculated value by two to get the duration for our whole trip that includes a call to ensure_visible. https://bugzilla.gnome.org/show_bug.cgi?id=722263
-rw-r--r--src/mapLocation.js32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/mapLocation.js b/src/mapLocation.js
index 631f05d1..6907fd0d 100644
--- a/src/mapLocation.js
+++ b/src/mapLocation.js
@@ -32,6 +32,10 @@ const Utils = imports.utils;
const Path = imports.path;
const _ = imports.gettext.gettext;
+const _MAX_DISTANCE = 19850; // half of Earth's curcumference (km)
+const _MIN_ANIMATION_DURATION = 2000; // msec
+const _MAX_ANIMATION_DURATION = 5000; // msec
+
// A map location object with an added accuracy.
const MapLocation = new Lang.Class({
Name: 'MapLocation',
@@ -68,6 +72,13 @@ const MapLocation = new Lang.Class({
*/
this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_CUBIC;
+
+ let fromLocation = new Geocode.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();
@@ -79,7 +90,7 @@ const MapLocation = new Lang.Class({
this._view.go_to(this.latitude, this.longitude);
}).bind(this));
- this._mapView.ensureVisible([this._getCurrentLocation(), this]);
+ this._mapView.ensureVisible([fromLocation, this]);
},
show: function(layer) {
@@ -132,11 +143,22 @@ const MapLocation = new Lang.Class({
}
},
- _getCurrentLocation: function() {
- return new Geocode.Location({
- latitude: this._view.get_center_latitude(),
- longitude: this._view.get_center_longitude()
+ _updateGoToDuration: function(fromLocation) {
+ let toLocation = new Geocode.Location({
+ latitude: this.latitude,
+ longitude: this.longitude
});
+
+ let distance = fromLocation.get_distance_from(toLocation);
+ let duration = (distance / _MAX_DISTANCE) * _MAX_ANIMATION_DURATION;
+
+ // Clamp duration
+ duration = Math.max(_MIN_ANIMATION_DURATION,
+ Math.min(duration, _MAX_ANIMATION_DURATION));
+
+ // We divide by two because Champlain treats both go_to and
+ // ensure_visible as 'goto' journeys with its own duration.
+ this._view.goto_animation_duration = duration / 2;
}
});
Utils.addSignalMethods(MapLocation.prototype);