[gnome-maps] mapLocation: set saner goto animation duration
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] mapLocation: set saner goto animation duration
- Date: Wed, 22 Jan 2014 21:02:23 +0000 (UTC)
commit 54ec97ba8d5c3e8e77c308b3f7be5e4f44008f71
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Wed Jan 15 14:09:47 2014 +0100
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
src/mapLocation.js | 32 +++++++++++++++++++++++++++-----
1 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/src/mapLocation.js b/src/mapLocation.js
index 631f05d..6907fd0 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]