javascript - Canceling an OpenLayers.Map current panTo tween if user begins dragging map -
i've noticed if user drags map before panto function completes, map continue pan in previous pan direction.
here's quick jsfiddle high pan duration make effect easy reproduce:
map.panto( xy ); // code jsfiddle link
is there straight forward way cancel current panning event if user begins drag map?
i fixed it, though i'm not sure if best way. basically, did put call pantween.stop in map's moveend event, set pantween's callback null, otherwise, loop continues -- see openlayers.tween stop`function here: http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/openlayers/tween.js
in summary, added these 3 lines @ end of init function:
map.events.register('moveend', map, function(){ this.pantween.callbacks=null; this.pantween.stop(); });
updated fiddle: http://jsfiddle.net/a8kk4/62/
Comments
Post a Comment