Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix movestart, move, moveend sequence on pan with animate:false

  • Loading branch information...
commit c6c1bf1f774a68202ac0ce16dfe8a46e5e30f496 1 parent f36fd5f
Éric Lemoine authored
Showing with 34 additions and 3 deletions.
  1. +4 −2 lib/OpenLayers/Map.js
  2. +30 −1 tests/Map.html
6 lib/OpenLayers/Map.js
View
@@ -1634,8 +1634,10 @@ OpenLayers.Map = OpenLayers.Class({
this.panTo(newCenterLonLat);
} else {
this.moveTo(newCenterLonLat);
- this.dragging = false;
- this.events.triggerEvent("moveend");
+ if(this.dragging) {
+ this.dragging = false;
+ this.events.triggerEvent("moveend");
+ }
}
}
}
31 tests/Map.html
View
@@ -1712,7 +1712,36 @@
t.eq(log[1], "move", "followed by move,");
t.eq(log[log.length-2], "move", "move again before we stop panning,");
t.eq(log[log.length-1], "moveend", "and moveend when we're done.");
-
+ }
+
+ function test_pan_no_anim_event_sequence(t) {
+ t.plan(4);
+
+ var log = [];
+ var map = new OpenLayers.Map("map");
+ map.addLayer(
+ new OpenLayers.Layer(null, {isBaseLayer: true})
+ );
+ map.setCenter(new OpenLayers.LonLat(0, 0), 5);
+ map.events.on({
+ "movestart": function() {
+ log.push("movestart");
+ },
+ "move": function() {
+ log.push("move");
+ },
+ "moveend": function() {
+ log.push("moveend");
+ }
+ });
+
+ map.pan(5,5, {animate: false});
+ t.eq(log.length, 3, "no more than 3 events happen.");
+ t.eq(log[0], "movestart", "pan sequence starts with movestart");
+ t.eq(log[1], "move", "followed by move,");
+ t.eq(log[2], "moveend", "and moveend when we're done.");
+
+ map.destroy();
}
// test if we can call updateSize before document.body is ready. updateOk
Please sign in to comment.
Something went wrong with that request. Please try again.