leaflet-js 0.6.beta4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/CHANGELOG.rdoc +3 -0
- data/leaflet-js.gemspec +2 -2
- data/lib/leaflet.draw/CHANGELOG.md +45 -0
- data/lib/leaflet.draw/README.md +70 -23
- data/lib/leaflet.draw/build/deps.js +1 -0
- data/lib/leaflet.draw/dist/images/spritesheet-2x.png +0 -0
- data/lib/leaflet.draw/dist/images/spritesheet.png +0 -0
- data/lib/leaflet.draw/dist/leaflet.draw-src.js +489 -136
- data/lib/leaflet.draw/dist/leaflet.draw.css +34 -2
- data/lib/leaflet.draw/dist/leaflet.draw.ie.css +5 -0
- data/lib/leaflet.draw/dist/leaflet.draw.js +2 -2
- data/lib/leaflet.draw/examples/basic.html +14 -7
- data/lib/leaflet.draw/examples/libs/images/layers-2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/layers.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon-2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/leaflet-src.js +1129 -608
- data/lib/leaflet.draw/examples/libs/leaflet.css +85 -66
- data/lib/leaflet.draw/package.json +2 -2
- data/lib/leaflet.draw/spec/suites/DrawControlSpec.js +1 -1
- data/lib/leaflet.draw/spec/suites/GeometryUtilSpec.js +25 -0
- data/lib/leaflet.draw/spec/suites/LatLngUtilSpec.js +9 -0
- data/lib/leaflet.draw/src/Control.Draw.js +1 -0
- data/lib/leaflet.draw/src/Leaflet.draw.js +89 -1
- data/lib/leaflet.draw/src/Toolbar.js +2 -6
- data/lib/leaflet.draw/src/Tooltip.js +20 -7
- data/lib/leaflet.draw/src/draw/DrawToolbar.js +26 -22
- data/lib/leaflet.draw/src/draw/handler/Draw.Circle.js +11 -6
- data/lib/leaflet.draw/src/draw/handler/Draw.Feature.js +6 -2
- data/lib/leaflet.draw/src/draw/handler/Draw.Marker.js +7 -2
- data/lib/leaflet.draw/src/draw/handler/Draw.Polygon.js +29 -7
- data/lib/leaflet.draw/src/draw/handler/Draw.Polyline.js +44 -21
- data/lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js +3 -3
- data/lib/leaflet.draw/src/draw/handler/Draw.SimpleShape.js +14 -1
- data/lib/leaflet.draw/src/edit/EditToolbar.js +86 -16
- data/lib/leaflet.draw/src/edit/handler/Edit.Poly.js +10 -7
- data/lib/leaflet.draw/src/edit/handler/Edit.SimpleShape.js +1 -2
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Delete.js +15 -3
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Edit.js +56 -38
- data/lib/leaflet.draw/src/ext/GeometryUtil.js +68 -0
- data/lib/leaflet.draw/src/images/spritesheet.svg +41 -0
- data/lib/leaflet.label/CHANGELOG.md +32 -0
- data/lib/leaflet.label/README.md +21 -4
- data/lib/leaflet.label/build/build.js +2 -2
- data/lib/leaflet.label/build/deps.js +2 -0
- data/lib/leaflet.label/build/hintrc.js +4 -0
- data/lib/leaflet.label/dist/leaflet.label-src.js +266 -83
- data/lib/leaflet.label/dist/leaflet.label.css +23 -4
- data/lib/leaflet.label/dist/leaflet.label.js +1 -1
- data/lib/leaflet.label/example/label.html +6 -3
- data/lib/leaflet.label/libs/leaflet/images/layers-2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/layers.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon-2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/leaflet-src.js +1129 -608
- data/lib/leaflet.label/libs/leaflet/leaflet.css +85 -66
- data/lib/leaflet.label/libs/leaflet/leaflet.js +6 -5
- data/lib/leaflet.label/package.json +19 -0
- data/lib/leaflet.label/src/BaseMarkerMethods.js +129 -0
- data/lib/leaflet.label/src/CircleMarker.Label.js +7 -0
- data/lib/leaflet.label/src/Label.js +161 -37
- data/lib/leaflet.label/src/Leaflet.label.js +1 -1
- data/lib/leaflet.label/src/Map.Label.js +0 -2
- data/lib/leaflet.label/src/Marker.Label.js +15 -120
- data/lib/leaflet.label/src/Path.Label.js +11 -11
- data/lib/leaflet/CHANGELOG.md +299 -31
- data/lib/leaflet/CONTRIBUTING.md +3 -3
- data/lib/leaflet/FAQ.md +138 -0
- data/lib/leaflet/Jakefile.js +24 -4
- data/lib/leaflet/PLUGIN-GUIDE.md +127 -0
- data/lib/leaflet/README.md +10 -6
- data/lib/leaflet/build/build.html +3 -19
- data/lib/leaflet/build/build.js +21 -51
- data/lib/leaflet/build/deps.js +10 -7
- data/lib/leaflet/build/hintrc.js +6 -4
- data/lib/leaflet/debug/hacks/jitter.html +0 -1
- data/lib/leaflet/debug/map/canvas.html +11 -12
- data/lib/leaflet/debug/map/controls.html +3 -4
- data/lib/leaflet/debug/map/geolocation.html +0 -1
- data/lib/leaflet/debug/map/iframe.html +11 -0
- data/lib/leaflet/debug/map/image-overlay.html +0 -1
- data/lib/leaflet/debug/map/map-mobile.html +0 -1
- data/lib/leaflet/debug/map/map.html +1 -2
- data/lib/leaflet/debug/map/max-bounds.html +2 -1
- data/lib/leaflet/debug/map/opacity.html +223 -0
- data/lib/leaflet/debug/map/scroll.html +6 -1
- data/lib/leaflet/debug/map/simple-proj.html +0 -1
- data/lib/leaflet/debug/map/wms-marble.html +4 -5
- data/lib/leaflet/debug/map/wms.html +0 -1
- data/lib/leaflet/debug/map/zoomlevels.html +0 -1
- data/lib/leaflet/debug/tests/add_remove_layers.html +5 -6
- data/lib/leaflet/debug/tests/bringtoback.html +0 -1
- data/lib/leaflet/debug/tests/canvasloop.html +47 -0
- data/lib/leaflet/debug/tests/click_on_canvas.html +0 -1
- data/lib/leaflet/debug/tests/dragging_and_copyworldjump.html +61 -0
- data/lib/leaflet/debug/tests/opacity.html +0 -1
- data/lib/leaflet/debug/tests/popupcontextmenuclicks.html +59 -0
- data/lib/leaflet/debug/tests/remove_while_dragging.html +4 -5
- data/lib/leaflet/debug/tests/removetilewhilepan.html +0 -1
- data/lib/leaflet/debug/tests/reuse_popups.html +0 -1
- data/lib/leaflet/debug/tests/rtl.html +42 -0
- data/lib/leaflet/debug/tests/rtl2.html +27 -0
- data/lib/leaflet/debug/tests/set_icon_reuse_dom.html +43 -0
- data/lib/leaflet/debug/tests/svg_clicks.html +3 -4
- data/lib/leaflet/debug/vector/bounds-extend.html +0 -1
- data/lib/leaflet/debug/vector/feature-group-bounds.html +0 -1
- data/lib/leaflet/debug/vector/geojson.html +0 -1
- data/lib/leaflet/debug/vector/rectangle.html +0 -1
- data/lib/leaflet/debug/vector/touchzoomemu.html +2 -3
- data/lib/leaflet/debug/vector/vector-bounds.html +0 -1
- data/lib/leaflet/debug/vector/vector-canvas.html +0 -1
- data/lib/leaflet/debug/vector/vector-mobile.html +0 -1
- data/lib/leaflet/debug/vector/vector-simple.html +0 -1
- data/lib/leaflet/debug/vector/vector.html +0 -1
- data/lib/leaflet/dist/images/layers-2x.png +0 -0
- data/lib/leaflet/dist/images/layers.png +0 -0
- data/lib/leaflet/dist/leaflet.css +85 -66
- data/lib/leaflet/package.json +25 -20
- data/lib/leaflet/spec/after.js +1 -1
- data/lib/leaflet/spec/index.html +21 -13
- data/lib/leaflet/spec/karma.conf.js +51 -50
- data/lib/leaflet/spec/spec.hintrc.js +25 -0
- data/lib/leaflet/spec/suites/LeafletSpec.js +2 -2
- data/lib/leaflet/spec/suites/SpecHelper.js +37 -21
- data/lib/leaflet/spec/suites/control/Control.LayersSpec.js +1 -1
- data/lib/leaflet/spec/suites/core/ClassSpec.js +12 -12
- data/lib/leaflet/spec/suites/core/EventsSpec.js +74 -18
- data/lib/leaflet/spec/suites/core/UtilSpec.js +69 -25
- data/lib/leaflet/spec/suites/dom/DomEventSpec.js +16 -16
- data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +9 -16
- data/lib/leaflet/spec/suites/dom/PosAnimationSpec.js +27 -0
- data/lib/leaflet/spec/suites/geo/CRSSpec.js +47 -0
- data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +22 -14
- data/lib/leaflet/spec/suites/geo/LatLngSpec.js +22 -8
- data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +21 -20
- data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +15 -15
- data/lib/leaflet/spec/suites/geometry/PointSpec.js +12 -12
- data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +4 -4
- data/lib/leaflet/spec/suites/layer/FeatureGroupSpec.js +59 -9
- data/lib/leaflet/spec/suites/layer/GeoJSONSpec.js +213 -17
- data/lib/leaflet/spec/suites/layer/LayerGroupSpec.js +6 -6
- data/lib/leaflet/spec/suites/layer/PopupSpec.js +65 -5
- data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +16 -15
- data/lib/leaflet/spec/suites/layer/marker/MarkerSpec.js +94 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleMarkerSpec.js +7 -7
- data/lib/leaflet/spec/suites/layer/vector/PolygonSpec.js +38 -2
- data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +4 -4
- data/lib/leaflet/spec/suites/layer/vector/PolylineSpec.js +2 -2
- data/lib/leaflet/spec/suites/map/MapSpec.js +318 -26
- data/lib/leaflet/spec/suites/map/handler/Map.DragSpec.js +38 -0
- data/lib/leaflet/src/Leaflet.js +2 -2
- data/lib/leaflet/src/control/Control.Attribution.js +6 -0
- data/lib/leaflet/src/control/Control.Layers.js +33 -24
- data/lib/leaflet/src/control/Control.Zoom.js +12 -4
- data/lib/leaflet/src/control/Control.js +10 -0
- data/lib/leaflet/src/copyright.js +2 -1
- data/lib/leaflet/src/core/Browser.js +11 -10
- data/lib/leaflet/src/core/Events.js +15 -11
- data/lib/leaflet/src/core/Util.js +19 -14
- data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +13 -12
- data/lib/leaflet/src/dom/DomEvent.Pointer.js +155 -0
- data/lib/leaflet/src/dom/DomEvent.js +57 -19
- data/lib/leaflet/src/dom/DomUtil.js +89 -34
- data/lib/leaflet/src/dom/Draggable.js +26 -89
- data/lib/leaflet/src/dom/PosAnimation.js +13 -2
- data/lib/leaflet/src/geo/LatLng.js +16 -5
- data/lib/leaflet/src/geo/LatLngBounds.js +5 -2
- data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +2 -2
- data/lib/leaflet/src/geo/crs/CRS.js +5 -0
- data/lib/leaflet/src/geo/projection/Projection.Mercator.js +3 -3
- data/lib/leaflet/src/geometry/LineUtil.js +2 -2
- data/lib/leaflet/src/images/layers.svg +8 -0
- data/lib/leaflet/src/images/marker.svg +61 -1
- data/lib/leaflet/src/layer/FeatureGroup.js +24 -7
- data/lib/leaflet/src/layer/GeoJSON.js +97 -56
- data/lib/leaflet/src/layer/ImageOverlay.js +9 -0
- data/lib/leaflet/src/layer/LayerGroup.js +8 -3
- data/lib/leaflet/src/layer/Popup.js +56 -34
- data/lib/leaflet/src/layer/marker/DivIcon.js +4 -2
- data/lib/leaflet/src/layer/marker/Icon.Default.js +1 -1
- data/lib/leaflet/src/layer/marker/Icon.js +15 -18
- data/lib/leaflet/src/layer/marker/Marker.Drag.js +7 -5
- data/lib/leaflet/src/layer/marker/Marker.Popup.js +22 -5
- data/lib/leaflet/src/layer/marker/Marker.js +75 -32
- data/lib/leaflet/src/layer/tile/TileLayer.Anim.js +14 -26
- data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +7 -6
- data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +14 -10
- data/lib/leaflet/src/layer/tile/TileLayer.js +53 -32
- data/lib/leaflet/src/layer/vector/CircleMarker.js +11 -0
- data/lib/leaflet/src/layer/vector/MultiPoly.js +10 -0
- data/lib/leaflet/src/layer/vector/Path.SVG.js +14 -3
- data/lib/leaflet/src/layer/vector/Path.VML.js +12 -2
- data/lib/leaflet/src/layer/vector/Path.js +7 -3
- data/lib/leaflet/src/layer/vector/Polygon.js +14 -3
- data/lib/leaflet/src/layer/vector/canvas/CircleMarker.Canvas.js +9 -0
- data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +1 -0
- data/lib/leaflet/src/map/Map.js +192 -125
- data/lib/leaflet/src/map/anim/Map.PanAnimation.js +29 -19
- data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +21 -9
- data/lib/leaflet/src/map/ext/Map.Geolocation.js +11 -4
- data/lib/leaflet/src/map/handler/Map.BoxZoom.js +26 -12
- data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +10 -3
- data/lib/leaflet/src/map/handler/Map.Drag.js +12 -6
- data/lib/leaflet/src/map/handler/Map.Keyboard.js +5 -2
- data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +7 -1
- data/lib/leaflet/src/map/handler/Map.Tap.js +107 -0
- data/lib/leaflet/src/map/handler/Map.TouchZoom.js +9 -3
- data/vendor/assets/images/layers-2x.png +0 -0
- data/vendor/assets/images/layers.png +0 -0
- data/vendor/assets/images/spritesheet-2x.png +0 -0
- data/vendor/assets/images/spritesheet.png +0 -0
- data/vendor/assets/javascripts/leaflet.draw.js +2 -4
- data/vendor/assets/javascripts/leaflet.js +3 -1
- data/vendor/assets/javascripts/leaflet.label.js +2 -0
- data/vendor/assets/stylesheets/leaflet.css.erb +337 -318
- data/vendor/assets/stylesheets/leaflet.draw.css.erb +35 -3
- data/vendor/assets/stylesheets/leaflet.draw.ie.css +5 -0
- data/vendor/assets/stylesheets/leaflet.label.css +23 -4
- metadata +40 -14
- data/lib/leaflet.draw/examples/libs/leaflet.ie.css +0 -51
- data/lib/leaflet.label/libs/leaflet/leaflet.ie.css +0 -51
- data/lib/leaflet/dist/leaflet-src.js +0 -8579
- data/lib/leaflet/dist/leaflet.ie.css +0 -51
- data/lib/leaflet/dist/leaflet.js +0 -8
- data/lib/leaflet/spec/happen.js +0 -93
- data/lib/leaflet/src/dom/DomEvent.MsTouch.js +0 -146
- data/vendor/assets/stylesheets/leaflet.ie.css +0 -51
@@ -4,8 +4,8 @@
|
|
4
4
|
|
5
5
|
L.extend(L.DomEvent, {
|
6
6
|
|
7
|
-
_touchstart: L.Browser.
|
8
|
-
_touchend: L.Browser.
|
7
|
+
_touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',
|
8
|
+
_touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend',
|
9
9
|
|
10
10
|
// inspired by Zepto touch code by Thomas Fuchs
|
11
11
|
addDoubleTapListener: function (obj, handler, id) {
|
@@ -21,7 +21,7 @@ L.extend(L.DomEvent, {
|
|
21
21
|
function onTouchStart(e) {
|
22
22
|
var count;
|
23
23
|
|
24
|
-
if (L.Browser.
|
24
|
+
if (L.Browser.pointer) {
|
25
25
|
trackedTouches.push(e.pointerId);
|
26
26
|
count = trackedTouches.length;
|
27
27
|
} else {
|
@@ -40,7 +40,7 @@ L.extend(L.DomEvent, {
|
|
40
40
|
}
|
41
41
|
|
42
42
|
function onTouchEnd(e) {
|
43
|
-
if (L.Browser.
|
43
|
+
if (L.Browser.pointer) {
|
44
44
|
var idx = trackedTouches.indexOf(e.pointerId);
|
45
45
|
if (idx === -1) {
|
46
46
|
return;
|
@@ -49,7 +49,7 @@ L.extend(L.DomEvent, {
|
|
49
49
|
}
|
50
50
|
|
51
51
|
if (doubleTap) {
|
52
|
-
if (L.Browser.
|
52
|
+
if (L.Browser.pointer) {
|
53
53
|
// work around .type being readonly with MSPointer* events
|
54
54
|
var newTouch = { },
|
55
55
|
prop;
|
@@ -73,15 +73,15 @@ L.extend(L.DomEvent, {
|
|
73
73
|
obj[pre + touchstart + id] = onTouchStart;
|
74
74
|
obj[pre + touchend + id] = onTouchEnd;
|
75
75
|
|
76
|
-
// on
|
76
|
+
// on pointer we need to listen on the document, otherwise a drag starting on the map and moving off screen
|
77
77
|
// will not come through to us, so we will lose track of how many touches are ongoing
|
78
|
-
var endElement = L.Browser.
|
78
|
+
var endElement = L.Browser.pointer ? document.documentElement : obj;
|
79
79
|
|
80
80
|
obj.addEventListener(touchstart, onTouchStart, false);
|
81
81
|
endElement.addEventListener(touchend, onTouchEnd, false);
|
82
82
|
|
83
|
-
if (L.Browser.
|
84
|
-
endElement.addEventListener(
|
83
|
+
if (L.Browser.pointer) {
|
84
|
+
endElement.addEventListener(L.DomEvent.POINTER_CANCEL, onTouchEnd, false);
|
85
85
|
}
|
86
86
|
|
87
87
|
return this;
|
@@ -91,11 +91,12 @@ L.extend(L.DomEvent, {
|
|
91
91
|
var pre = '_leaflet_';
|
92
92
|
|
93
93
|
obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false);
|
94
|
-
(L.Browser.
|
94
|
+
(L.Browser.pointer ? document.documentElement : obj).removeEventListener(
|
95
95
|
this._touchend, obj[pre + this._touchend + id], false);
|
96
96
|
|
97
|
-
if (L.Browser.
|
98
|
-
document.documentElement.removeEventListener(
|
97
|
+
if (L.Browser.pointer) {
|
98
|
+
document.documentElement.removeEventListener(L.DomEvent.POINTER_CANCEL, obj[pre + this._touchend + id],
|
99
|
+
false);
|
99
100
|
}
|
100
101
|
|
101
102
|
return this;
|
@@ -0,0 +1,155 @@
|
|
1
|
+
/*
|
2
|
+
* Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.extend(L.DomEvent, {
|
6
|
+
|
7
|
+
//static
|
8
|
+
POINTER_DOWN: L.Browser.msPointer ? 'MSPointerDown' : 'pointerdown',
|
9
|
+
POINTER_MOVE: L.Browser.msPointer ? 'MSPointerMove' : 'pointermove',
|
10
|
+
POINTER_UP: L.Browser.msPointer ? 'MSPointerUp' : 'pointerup',
|
11
|
+
POINTER_CANCEL: L.Browser.msPointer ? 'MSPointerCancel' : 'pointercancel',
|
12
|
+
|
13
|
+
_pointers: [],
|
14
|
+
_pointerDocumentListener: false,
|
15
|
+
|
16
|
+
// Provides a touch events wrapper for (ms)pointer events.
|
17
|
+
// Based on changes by veproza https://github.com/CloudMade/Leaflet/pull/1019
|
18
|
+
//ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890
|
19
|
+
|
20
|
+
addPointerListener: function (obj, type, handler, id) {
|
21
|
+
|
22
|
+
switch (type) {
|
23
|
+
case 'touchstart':
|
24
|
+
return this.addPointerListenerStart(obj, type, handler, id);
|
25
|
+
case 'touchend':
|
26
|
+
return this.addPointerListenerEnd(obj, type, handler, id);
|
27
|
+
case 'touchmove':
|
28
|
+
return this.addPointerListenerMove(obj, type, handler, id);
|
29
|
+
default:
|
30
|
+
throw 'Unknown touch event type';
|
31
|
+
}
|
32
|
+
},
|
33
|
+
|
34
|
+
addPointerListenerStart: function (obj, type, handler, id) {
|
35
|
+
var pre = '_leaflet_',
|
36
|
+
pointers = this._pointers;
|
37
|
+
|
38
|
+
var cb = function (e) {
|
39
|
+
|
40
|
+
L.DomEvent.preventDefault(e);
|
41
|
+
|
42
|
+
var alreadyInArray = false;
|
43
|
+
for (var i = 0; i < pointers.length; i++) {
|
44
|
+
if (pointers[i].pointerId === e.pointerId) {
|
45
|
+
alreadyInArray = true;
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
if (!alreadyInArray) {
|
50
|
+
pointers.push(e);
|
51
|
+
}
|
52
|
+
|
53
|
+
e.touches = pointers.slice();
|
54
|
+
e.changedTouches = [e];
|
55
|
+
|
56
|
+
handler(e);
|
57
|
+
};
|
58
|
+
|
59
|
+
obj[pre + 'touchstart' + id] = cb;
|
60
|
+
obj.addEventListener(this.POINTER_DOWN, cb, false);
|
61
|
+
|
62
|
+
// need to also listen for end events to keep the _pointers list accurate
|
63
|
+
// this needs to be on the body and never go away
|
64
|
+
if (!this._pointerDocumentListener) {
|
65
|
+
var internalCb = function (e) {
|
66
|
+
for (var i = 0; i < pointers.length; i++) {
|
67
|
+
if (pointers[i].pointerId === e.pointerId) {
|
68
|
+
pointers.splice(i, 1);
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
};
|
73
|
+
//We listen on the documentElement as any drags that end by moving the touch off the screen get fired there
|
74
|
+
document.documentElement.addEventListener(this.POINTER_UP, internalCb, false);
|
75
|
+
document.documentElement.addEventListener(this.POINTER_CANCEL, internalCb, false);
|
76
|
+
|
77
|
+
this._pointerDocumentListener = true;
|
78
|
+
}
|
79
|
+
|
80
|
+
return this;
|
81
|
+
},
|
82
|
+
|
83
|
+
addPointerListenerMove: function (obj, type, handler, id) {
|
84
|
+
var pre = '_leaflet_',
|
85
|
+
touches = this._pointers;
|
86
|
+
|
87
|
+
function cb(e) {
|
88
|
+
|
89
|
+
// don't fire touch moves when mouse isn't down
|
90
|
+
if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; }
|
91
|
+
|
92
|
+
for (var i = 0; i < touches.length; i++) {
|
93
|
+
if (touches[i].pointerId === e.pointerId) {
|
94
|
+
touches[i] = e;
|
95
|
+
break;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
e.touches = touches.slice();
|
100
|
+
e.changedTouches = [e];
|
101
|
+
|
102
|
+
handler(e);
|
103
|
+
}
|
104
|
+
|
105
|
+
obj[pre + 'touchmove' + id] = cb;
|
106
|
+
obj.addEventListener(this.POINTER_MOVE, cb, false);
|
107
|
+
|
108
|
+
return this;
|
109
|
+
},
|
110
|
+
|
111
|
+
addPointerListenerEnd: function (obj, type, handler, id) {
|
112
|
+
var pre = '_leaflet_',
|
113
|
+
touches = this._pointers;
|
114
|
+
|
115
|
+
var cb = function (e) {
|
116
|
+
for (var i = 0; i < touches.length; i++) {
|
117
|
+
if (touches[i].pointerId === e.pointerId) {
|
118
|
+
touches.splice(i, 1);
|
119
|
+
break;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
e.touches = touches.slice();
|
124
|
+
e.changedTouches = [e];
|
125
|
+
|
126
|
+
handler(e);
|
127
|
+
};
|
128
|
+
|
129
|
+
obj[pre + 'touchend' + id] = cb;
|
130
|
+
obj.addEventListener(this.POINTER_UP, cb, false);
|
131
|
+
obj.addEventListener(this.POINTER_CANCEL, cb, false);
|
132
|
+
|
133
|
+
return this;
|
134
|
+
},
|
135
|
+
|
136
|
+
removePointerListener: function (obj, type, id) {
|
137
|
+
var pre = '_leaflet_',
|
138
|
+
cb = obj[pre + type + id];
|
139
|
+
|
140
|
+
switch (type) {
|
141
|
+
case 'touchstart':
|
142
|
+
obj.removeEventListener(this.POINTER_DOWN, cb, false);
|
143
|
+
break;
|
144
|
+
case 'touchmove':
|
145
|
+
obj.removeEventListener(this.POINTER_MOVE, cb, false);
|
146
|
+
break;
|
147
|
+
case 'touchend':
|
148
|
+
obj.removeEventListener(this.POINTER_UP, cb, false);
|
149
|
+
obj.removeEventListener(this.POINTER_CANCEL, cb, false);
|
150
|
+
break;
|
151
|
+
}
|
152
|
+
|
153
|
+
return this;
|
154
|
+
}
|
155
|
+
});
|
@@ -16,8 +16,8 @@ L.DomEvent = {
|
|
16
16
|
return fn.call(context || obj, e || L.DomEvent._getEvent());
|
17
17
|
};
|
18
18
|
|
19
|
-
if (L.Browser.
|
20
|
-
return this.
|
19
|
+
if (L.Browser.pointer && type.indexOf('touch') === 0) {
|
20
|
+
return this.addPointerListener(obj, type, handler, id);
|
21
21
|
}
|
22
22
|
if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {
|
23
23
|
this.addDoubleTapListener(obj, handler, id);
|
@@ -69,8 +69,8 @@ L.DomEvent = {
|
|
69
69
|
|
70
70
|
if (!handler) { return this; }
|
71
71
|
|
72
|
-
if (L.Browser.
|
73
|
-
this.
|
72
|
+
if (L.Browser.pointer && type.indexOf('touch') === 0) {
|
73
|
+
this.removePointerListener(obj, type, id);
|
74
74
|
} else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {
|
75
75
|
this.removeDoubleTapListener(obj, id);
|
76
76
|
|
@@ -101,20 +101,29 @@ L.DomEvent = {
|
|
101
101
|
} else {
|
102
102
|
e.cancelBubble = true;
|
103
103
|
}
|
104
|
+
L.DomEvent._skipped(e);
|
105
|
+
|
104
106
|
return this;
|
105
107
|
},
|
106
108
|
|
107
|
-
|
109
|
+
disableScrollPropagation: function (el) {
|
110
|
+
var stop = L.DomEvent.stopPropagation;
|
108
111
|
|
112
|
+
return L.DomEvent
|
113
|
+
.on(el, 'mousewheel', stop)
|
114
|
+
.on(el, 'MozMousePixelScroll', stop);
|
115
|
+
},
|
116
|
+
|
117
|
+
disableClickPropagation: function (el) {
|
109
118
|
var stop = L.DomEvent.stopPropagation;
|
110
119
|
|
111
120
|
for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
|
112
|
-
L.DomEvent.
|
121
|
+
L.DomEvent.on(el, L.Draggable.START[i], stop);
|
113
122
|
}
|
114
123
|
|
115
124
|
return L.DomEvent
|
116
|
-
.
|
117
|
-
.
|
125
|
+
.on(el, 'click', L.DomEvent._fakeStop)
|
126
|
+
.on(el, 'dblclick', stop);
|
118
127
|
},
|
119
128
|
|
120
129
|
preventDefault: function (e) {
|
@@ -128,18 +137,32 @@ L.DomEvent = {
|
|
128
137
|
},
|
129
138
|
|
130
139
|
stop: function (e) {
|
131
|
-
return L.DomEvent
|
140
|
+
return L.DomEvent
|
141
|
+
.preventDefault(e)
|
142
|
+
.stopPropagation(e);
|
132
143
|
},
|
133
144
|
|
134
145
|
getMousePosition: function (e, container) {
|
135
|
-
|
136
146
|
var body = document.body,
|
137
147
|
docEl = document.documentElement,
|
138
|
-
|
139
|
-
|
148
|
+
//gecko makes scrollLeft more negative as you scroll in rtl, other browsers don't
|
149
|
+
//ref: https://code.google.com/p/closure-library/source/browse/closure/goog/style/bidi.js
|
150
|
+
x = L.DomUtil.documentIsLtr() ?
|
151
|
+
(e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft : e.clientX) :
|
152
|
+
(L.Browser.gecko ? e.pageX - body.scrollLeft - docEl.scrollLeft :
|
153
|
+
e.pageX ? e.pageX - body.scrollLeft + docEl.scrollLeft : e.clientX),
|
154
|
+
y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
|
140
155
|
pos = new L.Point(x, y);
|
141
156
|
|
142
|
-
|
157
|
+
if (!container) {
|
158
|
+
return pos;
|
159
|
+
}
|
160
|
+
|
161
|
+
var rect = container.getBoundingClientRect(),
|
162
|
+
left = rect.left - container.clientLeft,
|
163
|
+
top = rect.top - container.clientTop;
|
164
|
+
|
165
|
+
return pos._subtract(new L.Point(left, top));
|
143
166
|
},
|
144
167
|
|
145
168
|
getWheelDelta: function (e) {
|
@@ -155,6 +178,20 @@ L.DomEvent = {
|
|
155
178
|
return delta;
|
156
179
|
},
|
157
180
|
|
181
|
+
_skipEvents: {},
|
182
|
+
|
183
|
+
_fakeStop: function (e) {
|
184
|
+
// fakes stopPropagation by setting a special event flag, checked/reset with L.DomEvent._skipped(e)
|
185
|
+
L.DomEvent._skipEvents[e.type] = true;
|
186
|
+
},
|
187
|
+
|
188
|
+
_skipped: function (e) {
|
189
|
+
var skipped = this._skipEvents[e.type];
|
190
|
+
// reset when checking, as it's only used in map container and propagates outside of the map
|
191
|
+
this._skipEvents[e.type] = false;
|
192
|
+
return skipped;
|
193
|
+
},
|
194
|
+
|
158
195
|
// check if element really left/entered the event target (for mouseenter/mouseleave)
|
159
196
|
_checkMouse: function (el, e) {
|
160
197
|
|
@@ -188,16 +225,17 @@ L.DomEvent = {
|
|
188
225
|
return e;
|
189
226
|
},
|
190
227
|
|
191
|
-
// this
|
228
|
+
// this is a horrible workaround for a bug in Android where a single touch triggers two click events
|
192
229
|
_filterClick: function (e, handler) {
|
193
|
-
var timeStamp = (e.timeStamp || e.originalEvent.timeStamp)
|
194
|
-
|
230
|
+
var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),
|
231
|
+
elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
|
195
232
|
|
196
|
-
// are they closer together than
|
233
|
+
// are they closer together than 1000ms yet more than 100ms?
|
197
234
|
// Android typically triggers them ~300ms apart while multiple listeners
|
198
|
-
// on the same event should be triggered far faster
|
235
|
+
// on the same event should be triggered far faster;
|
236
|
+
// or check if click is simulated on the element, and if it is, reject any non-simulated events
|
199
237
|
|
200
|
-
if (elapsed && elapsed > 100 && elapsed <
|
238
|
+
if ((elapsed && elapsed > 100 && elapsed < 1000) || (e.target._simulatedClick && !e._simulated)) {
|
201
239
|
L.DomEvent.stop(e);
|
202
240
|
return;
|
203
241
|
}
|
@@ -30,8 +30,7 @@ L.DomUtil = {
|
|
30
30
|
el = element,
|
31
31
|
docBody = document.body,
|
32
32
|
docEl = document.documentElement,
|
33
|
-
pos
|
34
|
-
ie7 = L.Browser.ie7;
|
33
|
+
pos;
|
35
34
|
|
36
35
|
do {
|
37
36
|
top += el.offsetTop || 0;
|
@@ -50,6 +49,22 @@ L.DomUtil = {
|
|
50
49
|
left += docBody.scrollLeft || docEl.scrollLeft || 0;
|
51
50
|
break;
|
52
51
|
}
|
52
|
+
|
53
|
+
if (pos === 'relative' && !el.offsetLeft) {
|
54
|
+
var width = L.DomUtil.getStyle(el, 'width'),
|
55
|
+
maxWidth = L.DomUtil.getStyle(el, 'max-width'),
|
56
|
+
r = el.getBoundingClientRect();
|
57
|
+
|
58
|
+
if (width !== 'none' || maxWidth !== 'none') {
|
59
|
+
left += r.left + el.clientLeft;
|
60
|
+
}
|
61
|
+
|
62
|
+
//calculate full y offset since we're breaking out of the loop
|
63
|
+
top += r.top + (docBody.scrollTop || docEl.scrollTop || 0);
|
64
|
+
|
65
|
+
break;
|
66
|
+
}
|
67
|
+
|
53
68
|
el = el.offsetParent;
|
54
69
|
|
55
70
|
} while (el);
|
@@ -62,19 +77,6 @@ L.DomUtil = {
|
|
62
77
|
top -= el.scrollTop || 0;
|
63
78
|
left -= el.scrollLeft || 0;
|
64
79
|
|
65
|
-
// webkit (and ie <= 7) handles RTL scrollLeft different to everyone else
|
66
|
-
// https://code.google.com/p/closure-library/source/browse/trunk/closure/goog/style/bidi.js
|
67
|
-
if (!L.DomUtil.documentIsLtr() && (L.Browser.webkit || ie7)) {
|
68
|
-
left += el.scrollWidth - el.clientWidth;
|
69
|
-
|
70
|
-
// ie7 shows the scrollbar by default and provides clientWidth counting it, so we
|
71
|
-
// need to add it back in if it is visible; scrollbar is on the left as we are RTL
|
72
|
-
if (ie7 && L.DomUtil.getStyle(el, 'overflow-y') !== 'hidden' &&
|
73
|
-
L.DomUtil.getStyle(el, 'overflow') !== 'hidden') {
|
74
|
-
left += 17;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
80
|
el = el.parentNode;
|
79
81
|
} while (el);
|
80
82
|
|
@@ -101,36 +103,45 @@ L.DomUtil = {
|
|
101
103
|
return el;
|
102
104
|
},
|
103
105
|
|
104
|
-
|
105
|
-
if (
|
106
|
-
|
107
|
-
}
|
108
|
-
if (!this._onselectstart) {
|
109
|
-
this._onselectstart = document.onselectstart || null;
|
110
|
-
document.onselectstart = L.Util.falseFn;
|
106
|
+
hasClass: function (el, name) {
|
107
|
+
if (el.classList !== undefined) {
|
108
|
+
return el.classList.contains(name);
|
111
109
|
}
|
110
|
+
var className = L.DomUtil._getClass(el);
|
111
|
+
return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
|
112
112
|
},
|
113
113
|
|
114
|
-
|
115
|
-
if (
|
116
|
-
|
117
|
-
|
114
|
+
addClass: function (el, name) {
|
115
|
+
if (el.classList !== undefined) {
|
116
|
+
var classes = L.Util.splitWords(name);
|
117
|
+
for (var i = 0, len = classes.length; i < len; i++) {
|
118
|
+
el.classList.add(classes[i]);
|
119
|
+
}
|
120
|
+
} else if (!L.DomUtil.hasClass(el, name)) {
|
121
|
+
var className = L.DomUtil._getClass(el);
|
122
|
+
L.DomUtil._setClass(el, (className ? className + ' ' : '') + name);
|
118
123
|
}
|
119
124
|
},
|
120
125
|
|
121
|
-
|
122
|
-
|
123
|
-
|
126
|
+
removeClass: function (el, name) {
|
127
|
+
if (el.classList !== undefined) {
|
128
|
+
el.classList.remove(name);
|
129
|
+
} else {
|
130
|
+
L.DomUtil._setClass(el, L.Util.trim((' ' + L.DomUtil._getClass(el) + ' ').replace(' ' + name + ' ', ' ')));
|
131
|
+
}
|
124
132
|
},
|
125
133
|
|
126
|
-
|
127
|
-
if (
|
128
|
-
el.className
|
134
|
+
_setClass: function (el, name) {
|
135
|
+
if (el.className.baseVal === undefined) {
|
136
|
+
el.className = name;
|
137
|
+
} else {
|
138
|
+
// in case of SVG element
|
139
|
+
el.className.baseVal = name;
|
129
140
|
}
|
130
141
|
},
|
131
142
|
|
132
|
-
|
133
|
-
el.className
|
143
|
+
_getClass: function (el) {
|
144
|
+
return el.className.baseVal === undefined ? el.className : el.className.baseVal;
|
134
145
|
},
|
135
146
|
|
136
147
|
setOpacity: function (el, value) {
|
@@ -237,3 +248,47 @@ L.DomUtil.TRANSITION = L.DomUtil.testProp(
|
|
237
248
|
L.DomUtil.TRANSITION_END =
|
238
249
|
L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ?
|
239
250
|
L.DomUtil.TRANSITION + 'End' : 'transitionend';
|
251
|
+
|
252
|
+
(function () {
|
253
|
+
if ('onselectstart' in document) {
|
254
|
+
L.extend(L.DomUtil, {
|
255
|
+
disableTextSelection: function () {
|
256
|
+
L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault);
|
257
|
+
},
|
258
|
+
|
259
|
+
enableTextSelection: function () {
|
260
|
+
L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault);
|
261
|
+
}
|
262
|
+
});
|
263
|
+
} else {
|
264
|
+
var userSelectProperty = L.DomUtil.testProp(
|
265
|
+
['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']);
|
266
|
+
|
267
|
+
L.extend(L.DomUtil, {
|
268
|
+
disableTextSelection: function () {
|
269
|
+
if (userSelectProperty) {
|
270
|
+
var style = document.documentElement.style;
|
271
|
+
this._userSelect = style[userSelectProperty];
|
272
|
+
style[userSelectProperty] = 'none';
|
273
|
+
}
|
274
|
+
},
|
275
|
+
|
276
|
+
enableTextSelection: function () {
|
277
|
+
if (userSelectProperty) {
|
278
|
+
document.documentElement.style[userSelectProperty] = this._userSelect;
|
279
|
+
delete this._userSelect;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
});
|
283
|
+
}
|
284
|
+
|
285
|
+
L.extend(L.DomUtil, {
|
286
|
+
disableImageDrag: function () {
|
287
|
+
L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault);
|
288
|
+
},
|
289
|
+
|
290
|
+
enableImageDrag: function () {
|
291
|
+
L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault);
|
292
|
+
}
|
293
|
+
});
|
294
|
+
})();
|