Permalink
Browse files

Fast-forward mode

  • Loading branch information...
1 parent b265dde commit 29db5482a4070abb194f7e16ce8909a8664377e9 @tmcw tmcw committed Feb 4, 2012
Showing with 17 additions and 7 deletions.
  1. +8 −3 modestmaps.js
  2. +1 −1 modestmaps.min.js
  3. +2 −2 src/hash.js
  4. +3 −1 src/map.js
  5. +3 −0 src/mouse.js
View
@@ -992,6 +992,7 @@ var MM = com.modestmaps = {
mouseMove: function(e) {
if (this.prevMouse) {
+ this.map.fastForward = true;
this.map.panBy(
e.clientX - this.prevMouse.x,
e.clientY - this.prevMouse.y);
@@ -1006,6 +1007,8 @@ var MM = com.modestmaps = {
mouseUp: function(e) {
MM.removeEvent(document, 'mouseup', this._mouseUp);
MM.removeEvent(document, 'mousemove', this._mouseMove);
+ this.map.fastForward = false;
+ this.map.requestRedraw();
this.prevMouse = null;
this.map.parent.style.cursor = '';
@@ -1105,10 +1108,10 @@ var MM = com.modestmaps = {
}
},
- onMapMove: function(map) {
+ onMapMove: function(map, ff) {
// bail if we're moving the map (updating from a hash),
// or if the map has no zoom set
- if (this.movingMap || this.map.zoom === 0) {
+ if (ff || this.movingMap || this.map.zoom === 0) {
return false;
}
var hash = this.formatHash(map);
@@ -2360,6 +2363,8 @@ var MM = com.modestmaps = {
autoSize: null, // Boolean, true if we have a window resize listener
+ fastForward: false, // Boolean, true if current map moves are caused by a transient action
+
toString: function() {
return 'Map(#' + this.parent.id + ')';
},
@@ -2844,7 +2849,7 @@ var MM = com.modestmaps = {
this.layers[i].draw();
}
- this.dispatchCallback('drawn');
+ this.dispatchCallback('drawn', this.fastForward);
},
_redrawTimer: undefined,
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -65,10 +65,10 @@
}
},
- onMapMove: function(map) {
+ onMapMove: function(map, ff) {
// bail if we're moving the map (updating from a hash),
// or if the map has no zoom set
- if (this.movingMap || this.map.zoom === 0) {
+ if (ff || this.movingMap || this.map.zoom === 0) {
return false;
}
var hash = this.formatHash(map);
View
@@ -121,6 +121,8 @@
autoSize: null, // Boolean, true if we have a window resize listener
+ fastForward: false, // Boolean, true if current map moves are caused by a transient action
+
toString: function() {
return 'Map(#' + this.parent.id + ')';
},
@@ -605,7 +607,7 @@
this.layers[i].draw();
}
- this.dispatchCallback('drawn');
+ this.dispatchCallback('drawn', this.fastForward);
},
_redrawTimer: undefined,
View
@@ -142,6 +142,7 @@
mouseMove: function(e) {
if (this.prevMouse) {
+ this.map.fastForward = true;
this.map.panBy(
e.clientX - this.prevMouse.x,
e.clientY - this.prevMouse.y);
@@ -156,6 +157,8 @@
mouseUp: function(e) {
MM.removeEvent(document, 'mouseup', this._mouseUp);
MM.removeEvent(document, 'mousemove', this._mouseMove);
+ this.map.fastForward = false;
+ this.map.requestRedraw();
this.prevMouse = null;
this.map.parent.style.cursor = '';

0 comments on commit 29db548

Please sign in to comment.