update leaflet to 0.7.3 - but also keeping our canvas-related changes

This commit is contained in:
Jon Atkins 2014-06-25 22:43:30 +01:00
parent d84e49d0e3
commit 549496fbc0
2 changed files with 33 additions and 31 deletions

View File

@ -7,7 +7,7 @@
var oldL = window.L, var oldL = window.L,
L = {}; L = {};
L.version = '0.7.2'; L.version = '0.7.3';
// define Leaflet for Node module pattern loaders, including Browserify // define Leaflet for Node module pattern loaders, including Browserify
if (typeof module === 'object' && typeof module.exports === 'object') { if (typeof module === 'object' && typeof module.exports === 'object') {
@ -2104,13 +2104,13 @@ L.Map = L.Class.extend({
var loading = !this._loaded; var loading = !this._loaded;
this._loaded = true; this._loaded = true;
this.fire('viewreset', {hard: !preserveMapOffset});
if (loading) { if (loading) {
this.fire('load'); this.fire('load');
this.eachLayer(this._layerAdd, this); this.eachLayer(this._layerAdd, this);
} }
this.fire('viewreset', {hard: !preserveMapOffset});
this.fire('move'); this.fire('move');
if (zoomChanged || afterZoomAnim) { if (zoomChanged || afterZoomAnim) {
@ -5108,7 +5108,8 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
} }
this._requestUpdate(); this._requestUpdate();
this.fire('remove');
this._map = null; this._map = null;
}, },
@ -6631,12 +6632,12 @@ L.DomEvent = {
var timeStamp = (e.timeStamp || e.originalEvent.timeStamp), var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),
elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick); elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
// are they closer together than 1000ms yet more than 100ms? // are they closer together than 500ms yet more than 100ms?
// Android typically triggers them ~300ms apart while multiple listeners // Android typically triggers them ~300ms apart while multiple listeners
// on the same event should be triggered far faster; // on the same event should be triggered far faster;
// or check if click is simulated on the element, and if it is, reject any non-simulated events // or check if click is simulated on the element, and if it is, reject any non-simulated events
if ((elapsed && elapsed > 100 && elapsed < 1000) || (e.target._simulatedClick && !e._simulated)) { if ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {
L.DomEvent.stop(e); L.DomEvent.stop(e);
return; return;
} }
@ -6734,6 +6735,7 @@ L.Draggable = L.Class.extend({
offset = newPoint.subtract(this._startPoint); offset = newPoint.subtract(this._startPoint);
if (!offset.x && !offset.y) { return; } if (!offset.x && !offset.y) { return; }
if (L.Browser.touch && Math.abs(offset.x) + Math.abs(offset.y) < 3) { return; }
L.DomEvent.preventDefault(e); L.DomEvent.preventDefault(e);
@ -6744,7 +6746,8 @@ L.Draggable = L.Class.extend({
this._startPos = L.DomUtil.getPosition(this._element).subtract(offset); this._startPos = L.DomUtil.getPosition(this._element).subtract(offset);
L.DomUtil.addClass(document.body, 'leaflet-dragging'); L.DomUtil.addClass(document.body, 'leaflet-dragging');
L.DomUtil.addClass((e.target || e.srcElement), 'leaflet-drag-target'); this._lastTarget = e.target || e.srcElement;
L.DomUtil.addClass(this._lastTarget, 'leaflet-drag-target');
} }
this._newPos = this._startPos.add(offset); this._newPos = this._startPos.add(offset);
@ -6760,9 +6763,13 @@ L.Draggable = L.Class.extend({
this.fire('drag'); this.fire('drag');
}, },
_onUp: function (e) { _onUp: function () {
L.DomUtil.removeClass(document.body, 'leaflet-dragging'); L.DomUtil.removeClass(document.body, 'leaflet-dragging');
L.DomUtil.removeClass((e.target || e.srcElement), 'leaflet-drag-target');
if (this._lastTarget) {
L.DomUtil.removeClass(this._lastTarget, 'leaflet-drag-target');
this._lastTarget = null;
}
for (var i in L.Draggable.MOVE) { for (var i in L.Draggable.MOVE) {
L.DomEvent L.DomEvent
@ -7417,7 +7424,7 @@ L.Map.TouchZoom = L.Handler.extend({
center = map.layerPointToLatLng(origin), center = map.layerPointToLatLng(origin),
zoom = map.getScaleZoom(this._scale); zoom = map.getScaleZoom(this._scale);
map._animateZoom(center, zoom, this._startCenter, this._scale, this._delta); map._animateZoom(center, zoom, this._startCenter, this._scale, this._delta, false, true);
}, },
_onTouchEnd: function () { _onTouchEnd: function () {
@ -8402,8 +8409,8 @@ L.Control.Layers = L.Control.extend({
onRemove: function (map) { onRemove: function (map) {
map map
.off('layeradd', this._onLayerChange) .off('layeradd', this._onLayerChange, this)
.off('layerremove', this._onLayerChange); .off('layerremove', this._onLayerChange, this);
}, },
addBaseLayer: function (layer, name) { addBaseLayer: function (layer, name) {
@ -8944,9 +8951,11 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
return true; return true;
}, },
_animateZoom: function (center, zoom, origin, scale, delta, backwards) { _animateZoom: function (center, zoom, origin, scale, delta, backwards, forTouchZoom) {
this._animatingZoom = true; if (!forTouchZoom) {
this._animatingZoom = true;
}
// put transform transition on all layers with leaflet-zoom-animated class // put transform transition on all layers with leaflet-zoom-animated class
L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim'); L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim');
@ -8960,14 +8969,16 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
L.Draggable._disabled = true; L.Draggable._disabled = true;
} }
this.fire('zoomanim', { L.Util.requestAnimFrame(function () {
center: center, this.fire('zoomanim', {
zoom: zoom, center: center,
origin: origin, zoom: zoom,
scale: scale, origin: origin,
delta: delta, scale: scale,
backwards: backwards delta: delta,
}); backwards: backwards
});
}, this);
}, },
_onZoomTransitionEnd: function () { _onZoomTransitionEnd: function () {

9
external/leaflet.js vendored

File diff suppressed because one or more lines are too long