|
@@ -0,0 +1,198 @@
|
|
1
|
+(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
2
|
+(function (global){
|
|
3
|
+var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null)
|
|
4
|
+require('./layout.css')
|
|
5
|
+require('./range.css')
|
|
6
|
+
|
|
7
|
+var mapWasDragEnabled
|
|
8
|
+
|
|
9
|
+// Leaflet v0.7 backwards compatibility
|
|
10
|
+function on (el, types, fn, context) {
|
|
11
|
+ types.split(' ').forEach(function (type) {
|
|
12
|
+ L.DomEvent.on(el, type, fn, context)
|
|
13
|
+ })
|
|
14
|
+}
|
|
15
|
+
|
|
16
|
+function off (el, types, fn, context) {
|
|
17
|
+ types.split(' ').forEach(function (type) {
|
|
18
|
+ L.DomEvent.off(el, type, fn, context)
|
|
19
|
+ })
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+function getRangeEvent (rangeInput) {
|
|
23
|
+ return 'oninput' in rangeInput ? 'input' : 'change'
|
|
24
|
+}
|
|
25
|
+
|
|
26
|
+function cancelMapDrag () {
|
|
27
|
+ mapWasDragEnabled = this._map.dragging.enabled()
|
|
28
|
+ this._map.dragging.disable()
|
|
29
|
+}
|
|
30
|
+
|
|
31
|
+function uncancelMapDrag (e) {
|
|
32
|
+ if (!mapWasDragEnabled) return
|
|
33
|
+ this._refocusOnMap(e)
|
|
34
|
+ this._map.dragging.enable()
|
|
35
|
+}
|
|
36
|
+
|
|
37
|
+function noop () {
|
|
38
|
+ return
|
|
39
|
+}
|
|
40
|
+
|
|
41
|
+L.Control.SideBySide = L.Control.extend({
|
|
42
|
+ initialize: function (leftLayers, rightLayers) {
|
|
43
|
+ this._leftLayers = Array.isArray(leftLayers) ? leftLayers : [leftLayers]
|
|
44
|
+ this._rightLayers = Array.isArray(rightLayers) ? rightLayers : [rightLayers]
|
|
45
|
+ },
|
|
46
|
+
|
|
47
|
+ getPosition: noop,
|
|
48
|
+
|
|
49
|
+ setPosition: noop,
|
|
50
|
+
|
|
51
|
+ addTo: function (map) {
|
|
52
|
+ this.remove()
|
|
53
|
+ this._map = map
|
|
54
|
+
|
|
55
|
+ var container = this._container = L.DomUtil.create('div', 'leaflet-sbs', map._controlContainer)
|
|
56
|
+
|
|
57
|
+ this._divider = L.DomUtil.create('div', 'leaflet-sbs-divider', container)
|
|
58
|
+ var range = this._range = L.DomUtil.create('input', 'leaflet-sbs-range', container)
|
|
59
|
+ range.type = 'range'
|
|
60
|
+ range.min = 0
|
|
61
|
+ range.max = 1
|
|
62
|
+ range.step = 'any'
|
|
63
|
+ this._addEvents()
|
|
64
|
+ this._updateLayers()
|
|
65
|
+ this._updateClip()
|
|
66
|
+ return this
|
|
67
|
+ },
|
|
68
|
+
|
|
69
|
+ remove: function () {
|
|
70
|
+ if (!this._map) {
|
|
71
|
+ return this
|
|
72
|
+ }
|
|
73
|
+ this._removeEvents()
|
|
74
|
+ L.DomUtil.remove(this._container)
|
|
75
|
+
|
|
76
|
+ this._map = null
|
|
77
|
+
|
|
78
|
+ return this
|
|
79
|
+ },
|
|
80
|
+
|
|
81
|
+ _updateClip: function () {
|
|
82
|
+ var map = this._map
|
|
83
|
+ var rangeValue = this._range.value
|
|
84
|
+ var nw = map.containerPointToLayerPoint([0, 0])
|
|
85
|
+ var se = map.containerPointToLayerPoint(map.getSize())
|
|
86
|
+ var offset = (0.5 - rangeValue) * 44
|
|
87
|
+ var clipX = nw.x + (se.x - nw.x) * rangeValue + offset
|
|
88
|
+
|
|
89
|
+ this._divider.style.left = map.getSize().x * rangeValue + offset + 'px'
|
|
90
|
+ var clipLeft = 'rect(' + [nw.y, clipX, se.y, nw.x].join('px,') + 'px)'
|
|
91
|
+ var clipRight = 'rect(' + [nw.y, se.x, se.y, clipX].join('px,') + 'px)'
|
|
92
|
+ if (this._leftLayer) {
|
|
93
|
+ this._leftLayer.getContainer().style.clip = clipLeft
|
|
94
|
+ }
|
|
95
|
+ if (this._rightLayer) {
|
|
96
|
+ this._rightLayer.getContainer().style.clip = clipRight
|
|
97
|
+ }
|
|
98
|
+ },
|
|
99
|
+
|
|
100
|
+ _updateLayers: function () {
|
|
101
|
+ this._leftLayer = this._rightLayer = null
|
|
102
|
+ this._leftLayers.forEach(function (layer) {
|
|
103
|
+ if (this._map.hasLayer(layer)) this._leftLayer = layer
|
|
104
|
+ }, this)
|
|
105
|
+ this._rightLayers.forEach(function (layer) {
|
|
106
|
+ if (this._map.hasLayer(layer)) this._rightLayer = layer
|
|
107
|
+ }, this)
|
|
108
|
+ this._updateClip()
|
|
109
|
+ },
|
|
110
|
+
|
|
111
|
+ _addEvents: function () {
|
|
112
|
+ var range = this._range
|
|
113
|
+ var map = this._map
|
|
114
|
+ if (!map || !range) return
|
|
115
|
+ map.on('move', this._updateClip, this)
|
|
116
|
+ map.on('layeradd layerremove', this._updateLayers, this)
|
|
117
|
+ on(range, getRangeEvent(range), this._updateClip, this)
|
|
118
|
+ on(range, 'mousedown touchstart', cancelMapDrag, this)
|
|
119
|
+ on(range, 'mouseup touchend', uncancelMapDrag, this)
|
|
120
|
+ },
|
|
121
|
+
|
|
122
|
+ _removeEvents: function () {
|
|
123
|
+ var range = this._range
|
|
124
|
+ var map = this._map
|
|
125
|
+ if (range) {
|
|
126
|
+ off(range, getRangeEvent(range), this._updateClip, this)
|
|
127
|
+ off(range, 'mousedown touchstart', cancelMapDrag, this)
|
|
128
|
+ off(range, 'mouseup touchend', uncancelMapDrag, this)
|
|
129
|
+ }
|
|
130
|
+ if (map) {
|
|
131
|
+ map.off('layeradd layerremove', this._updateLayers, this)
|
|
132
|
+ map.off('move', this._updateClip, this)
|
|
133
|
+ }
|
|
134
|
+ }
|
|
135
|
+})
|
|
136
|
+
|
|
137
|
+L.Control.sideBySide = function (leftLayers, rightLayers, options) {
|
|
138
|
+ return new L.Control.SideBySide(leftLayers, rightLayers, options)
|
|
139
|
+}
|
|
140
|
+
|
|
141
|
+module.export = L.Control.sideBySide
|
|
142
|
+
|
|
143
|
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
144
|
+},{"./layout.css":2,"./range.css":4}],2:[function(require,module,exports){
|
|
145
|
+var css = ".leaflet-sbs-range {\n position: absolute;\n top: 50%;\n width: 100%;\n z-index: 999;\n}\n.leaflet-sbs-divider {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n margin-left: -2px;\n width: 4px;\n background-color: #fff;\n pointer-events: none;\n z-index: 999;\n}\n"; (require("./node_modules/cssify"))(css, undefined, '/Users/gregor/Dev/DdDev/leaflet-side-by-side/layout.css'); module.exports = css;
|
|
146
|
+},{"./node_modules/cssify":3}],3:[function(require,module,exports){
|
|
147
|
+function injectStyleTag(document, fileName, cb) {
|
|
148
|
+ var style = document.getElementById(fileName);
|
|
149
|
+
|
|
150
|
+ if (style) {
|
|
151
|
+ cb(style);
|
|
152
|
+ } else {
|
|
153
|
+ var head = document.getElementsByTagName('head')[0];
|
|
154
|
+
|
|
155
|
+ style = document.createElement('style');
|
|
156
|
+ style.id = fileName;
|
|
157
|
+ cb(style);
|
|
158
|
+ head.appendChild(style);
|
|
159
|
+ }
|
|
160
|
+
|
|
161
|
+ return style;
|
|
162
|
+}
|
|
163
|
+
|
|
164
|
+module.exports = function (css, customDocument, fileName) {
|
|
165
|
+ var doc = customDocument || document;
|
|
166
|
+ if (doc.createStyleSheet) {
|
|
167
|
+ var sheet = doc.createStyleSheet()
|
|
168
|
+ sheet.cssText = css;
|
|
169
|
+ return sheet.ownerNode;
|
|
170
|
+ } else {
|
|
171
|
+ return injectStyleTag(doc, fileName, function(style) {
|
|
172
|
+ if (style.styleSheet) {
|
|
173
|
+ style.styleSheet.cssText = css;
|
|
174
|
+ } else {
|
|
175
|
+ style.innerHTML = css;
|
|
176
|
+ }
|
|
177
|
+ });
|
|
178
|
+ }
|
|
179
|
+};
|
|
180
|
+
|
|
181
|
+module.exports.byUrl = function(url) {
|
|
182
|
+ if (document.createStyleSheet) {
|
|
183
|
+ return document.createStyleSheet(url).ownerNode;
|
|
184
|
+ } else {
|
|
185
|
+ var head = document.getElementsByTagName('head')[0],
|
|
186
|
+ link = document.createElement('link');
|
|
187
|
+
|
|
188
|
+ link.rel = 'stylesheet';
|
|
189
|
+ link.href = url;
|
|
190
|
+
|
|
191
|
+ head.appendChild(link);
|
|
192
|
+ return link;
|
|
193
|
+ }
|
|
194
|
+};
|
|
195
|
+
|
|
196
|
+},{}],4:[function(require,module,exports){
|
|
197
|
+var css = ".leaflet-sbs-range,\n.leaflet-sbs-range::-webkit-slider-thumb {\n -webkit-appearance: none;\n margin: 0;\n padding: 0;\n border: 0;\n}\n.leaflet-sbs-range {\n display: inline-block!important;\n vertical-align: middle;\n height: 0;\n padding: 0;\n margin: 0;\n border: 0;\n background: rgba(0, 0, 0, 0.25);\n min-width: 100px;\n cursor: pointer;\n pointer-events: none;\n z-index: 999;\n}\n.leaflet-sbs-range::-ms-fill-upper {\n background: transparent;\n}\n.leaflet-sbs-range::-ms-fill-lower {\n background: rgba(255, 255, 255, 0.25);\n}\n/* Browser thingies */\n\n.leaflet-sbs-range::-moz-range-track {\n opacity: 0;\n}\n.leaflet-sbs-range::-ms-track {\n opacity: 0;\n}\n.leaflet-sbs-range::-ms-tooltip {\n display: none;\n}\n/* For whatever reason, these need to be defined\n * on their own so dont group them */\n\n.leaflet-sbs-range::-webkit-slider-thumb {\n background: #fff;\n height: 40px;\n width: 40px;\n border-radius: 20px;\n cursor: ew-resize;\n pointer-events: auto;\n border: 1px solid #ddd;\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAAABlBMVEV9fX3///+Kct39AAAAAnRSTlP/AOW3MEoAAAA9SURBVFjD7dehDQAwDANBZ/+l2wmKoiqR7pHRcaeaCxAIBAL/g7k9JxAIBAKBQCAQCAQC14H+MhAIBE4CD3fOFvGVBzhZAAAAAElFTkSuQmCC\");\n background-position: 50% 50%;\n background-repeat: no-repeat;\n background-size: 40px 40px;\n}\n.leaflet-sbs-range::-ms-thumb {\n margin: 0;\n padding: 0;\n background: #fff;\n height: 40px;\n width: 40px;\n border-radius: 20px;\n cursor: ew-resize;\n pointer-events: auto;\n border: 1px solid #ddd;\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAAABlBMVEV9fX3///+Kct39AAAAAnRSTlP/AOW3MEoAAAA9SURBVFjD7dehDQAwDANBZ/+l2wmKoiqR7pHRcaeaCxAIBAL/g7k9JxAIBAKBQCAQCAQC14H+MhAIBE4CD3fOFvGVBzhZAAAAAElFTkSuQmCC\");\n background-position: 50% 50%;\n background-repeat: no-repeat;\n background-size: 40px 40px;\n}\n.leaflet-sbs-range::-moz-range-thumb {\n padding: 0;\n right: 0 ;\n background: #fff;\n height: 40px;\n width: 40px;\n border-radius: 20px;\n cursor: ew-resize;\n pointer-events: auto;\n border: 1px solid #ddd;\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAAABlBMVEV9fX3///+Kct39AAAAAnRSTlP/AOW3MEoAAAA9SURBVFjD7dehDQAwDANBZ/+l2wmKoiqR7pHRcaeaCxAIBAL/g7k9JxAIBAKBQCAQCAQC14H+MhAIBE4CD3fOFvGVBzhZAAAAAElFTkSuQmCC\");\n background-position: 50% 50%;\n background-repeat: no-repeat;\n background-size: 40px 40px;\n}\n.leaflet-sbs-range:disabled::-moz-range-thumb {\n cursor: default;\n}\n.leaflet-sbs-range:disabled::-ms-thumb {\n cursor: default;\n}\n.leaflet-sbs-range:disabled::-webkit-slider-thumb {\n cursor: default;\n}\n.leaflet-sbs-range:disabled {\n cursor: default;\n}\n.leaflet-sbs-range:focus {\n outline: none!important;\n}\n.leaflet-sbs-range::-moz-focus-outer {\n border: 0;\n}\n\n"; (require("./node_modules/cssify"))(css, undefined, '/Users/gregor/Dev/DdDev/leaflet-side-by-side/range.css'); module.exports = css;
|
|
198
|
+},{"./node_modules/cssify":3}]},{},[1]);
|