Skip to content

Commit

Permalink
fix movestart, move, moveend sequence on pan with animate:false
Browse files Browse the repository at this point in the history
  • Loading branch information
elemoine committed Apr 23, 2012
1 parent f36fd5f commit c6c1bf1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/OpenLayers/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
}
Expand Down
31 changes: 30 additions & 1 deletion tests/Map.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c6c1bf1

Please sign in to comment.