您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

leaflet-side-by-side.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. var mapWasDragEnabled
  7. var mapWasTapEnabled
  8. // Leaflet v0.7 backwards compatibility
  9. function on (el, types, fn, context) {
  10. types.split(' ').forEach(function (type) {
  11. L.DomEvent.on(el, type, fn, context)
  12. })
  13. }
  14. // Leaflet v0.7 backwards compatibility
  15. function off (el, types, fn, context) {
  16. types.split(' ').forEach(function (type) {
  17. L.DomEvent.off(el, type, fn, context)
  18. })
  19. }
  20. function getRangeEvent (rangeInput) {
  21. return 'oninput' in rangeInput ? 'input' : 'change'
  22. }
  23. function cancelMapDrag () {
  24. mapWasDragEnabled = this._map.dragging.enabled()
  25. mapWasTapEnabled = this._map.tap && this._map.tap.enabled()
  26. this._map.dragging.disable()
  27. this._map.tap && this._map.tap.disable()
  28. }
  29. function uncancelMapDrag (e) {
  30. this._refocusOnMap(e)
  31. if (mapWasDragEnabled) {
  32. this._map.dragging.enable()
  33. }
  34. if (mapWasTapEnabled) {
  35. this._map.tap.enable()
  36. }
  37. }
  38. // convert arg to an array - returns empty array if arg is undefined
  39. function asArray (arg) {
  40. return (arg === 'undefined') ? [] : Array.isArray(arg) ? arg : [arg]
  41. }
  42. function noop () {
  43. return
  44. }
  45. L.Control.SideBySide = L.Control.extend({
  46. options: {
  47. thumbSize: 42,
  48. padding: 0
  49. },
  50. initialize: function (leftLayers, rightLayers, options) {
  51. this.setLeftLayers(leftLayers)
  52. this.setRightLayers(rightLayers)
  53. L.setOptions(this, options)
  54. },
  55. getPosition: function () {
  56. var rangeValue = this._range.value
  57. var offset = (0.5 - rangeValue) * (2 * this.options.padding + this.options.thumbSize)
  58. return this._map.getSize().x * rangeValue + offset
  59. },
  60. setPosition: noop,
  61. includes: L.Mixin.Events,
  62. addTo: function (map) {
  63. this.remove()
  64. this._map = map
  65. var container = this._container = L.DomUtil.create('div', 'leaflet-sbs', map._controlContainer)
  66. this._divider = L.DomUtil.create('div', 'leaflet-sbs-divider', container)
  67. var range = this._range = L.DomUtil.create('input', 'leaflet-sbs-range', container)
  68. range.type = 'range'
  69. range.min = 0
  70. range.max = 1
  71. range.step = 'any'
  72. range.value = 0.5
  73. range.style.paddingLeft = range.style.paddingRight = this.options.padding + 'px'
  74. this._addEvents()
  75. this._updateLayers()
  76. return this
  77. },
  78. remove: function () {
  79. if (!this._map) {
  80. return this
  81. }
  82. this._removeEvents()
  83. L.DomUtil.remove(this._container)
  84. this._map = null
  85. return this
  86. },
  87. setLeftLayers: function (leftLayers) {
  88. this._leftLayers = asArray(leftLayers)
  89. this._updateLayers()
  90. return this
  91. },
  92. setRightLayers: function (rightLayers) {
  93. this._rightLayers = asArray(rightLayers)
  94. this._updateLayers()
  95. return this
  96. },
  97. _updateClip: function () {
  98. var map = this._map
  99. var nw = map.containerPointToLayerPoint([0, 0])
  100. var se = map.containerPointToLayerPoint(map.getSize())
  101. var clipX = nw.x + this.getPosition()
  102. var dividerX = this.getPosition()
  103. this._divider.style.left = dividerX + 'px'
  104. this.fire('dividermove', {x: dividerX})
  105. var clipLeft = 'rect(' + [nw.y, clipX, se.y, nw.x].join('px,') + 'px)'
  106. var clipRight = 'rect(' + [nw.y, se.x, se.y, clipX].join('px,') + 'px)'
  107. if (this._leftLayer) {
  108. this._leftLayer.getContainer().style.clip = clipLeft
  109. }
  110. if (this._rightLayer) {
  111. this._rightLayer.getContainer().style.clip = clipRight
  112. }
  113. },
  114. _updateLayers: function () {
  115. if (!this._map) {
  116. return this
  117. }
  118. var prevLeft = this._leftLayer
  119. var prevRight = this._rightLayer
  120. this._leftLayer = this._rightLayer = null
  121. this._leftLayers.forEach(function (layer) {
  122. if (this._map.hasLayer(layer)) {
  123. this._leftLayer = layer
  124. }
  125. }, this)
  126. this._rightLayers.forEach(function (layer) {
  127. if (this._map.hasLayer(layer)) {
  128. this._rightLayer = layer
  129. }
  130. }, this)
  131. if (prevLeft !== this._leftLayer) {
  132. prevLeft && this.fire('leftlayerremove', {layer: prevLeft})
  133. this._leftLayer && this.fire('leftlayeradd', {layer: this._leftLayer})
  134. }
  135. if (prevRight !== this._rightLayer) {
  136. prevRight && this.fire('rightlayerremove', {layer: prevRight})
  137. this._rightLayer && this.fire('rightlayeradd', {layer: this._rightLayer})
  138. }
  139. this._updateClip()
  140. },
  141. _addEvents: function () {
  142. var range = this._range
  143. var map = this._map
  144. if (!map || !range) return
  145. map.on('move', this._updateClip, this)
  146. map.on('layeradd layerremove', this._updateLayers, this)
  147. on(range, getRangeEvent(range), this._updateClip, this)
  148. on(range, 'mousedown touchstart', cancelMapDrag, this)
  149. on(range, 'mouseup touchend', uncancelMapDrag, this)
  150. },
  151. _removeEvents: function () {
  152. var range = this._range
  153. var map = this._map
  154. if (range) {
  155. off(range, getRangeEvent(range), this._updateClip, this)
  156. off(range, 'mousedown touchstart', cancelMapDrag, this)
  157. off(range, 'mouseup touchend', uncancelMapDrag, this)
  158. }
  159. if (map) {
  160. map.off('layeradd layerremove', this._updateLayers, this)
  161. map.off('move', this._updateClip, this)
  162. }
  163. }
  164. })
  165. L.control.sideBySide = function (leftLayers, rightLayers, options) {
  166. return new L.Control.SideBySide(leftLayers, rightLayers, options)
  167. }
  168. module.exports = L.Control.SideBySide
  169. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  170. },{"./layout.css":2,"./range.css":4}],2:[function(require,module,exports){
  171. 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;
  172. },{"./node_modules/cssify":3}],3:[function(require,module,exports){
  173. function injectStyleTag(document, fileName, cb) {
  174. var style = document.getElementById(fileName);
  175. if (style) {
  176. cb(style);
  177. } else {
  178. var head = document.getElementsByTagName('head')[0];
  179. style = document.createElement('style');
  180. style.id = fileName;
  181. cb(style);
  182. head.appendChild(style);
  183. }
  184. return style;
  185. }
  186. module.exports = function (css, customDocument, fileName) {
  187. var doc = customDocument || document;
  188. if (doc.createStyleSheet) {
  189. var sheet = doc.createStyleSheet()
  190. sheet.cssText = css;
  191. return sheet.ownerNode;
  192. } else {
  193. return injectStyleTag(doc, fileName, function(style) {
  194. if (style.styleSheet) {
  195. style.styleSheet.cssText = css;
  196. } else {
  197. style.innerHTML = css;
  198. }
  199. });
  200. }
  201. };
  202. module.exports.byUrl = function(url) {
  203. if (document.createStyleSheet) {
  204. return document.createStyleSheet(url).ownerNode;
  205. } else {
  206. var head = document.getElementsByTagName('head')[0],
  207. link = document.createElement('link');
  208. link.rel = 'stylesheet';
  209. link.href = url;
  210. head.appendChild(link);
  211. return link;
  212. }
  213. };
  214. },{}],4:[function(require,module,exports){
  215. var css = ".leaflet-sbs-range {\n -webkit-appearance: none;\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 -webkit-appearance: none;\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::-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;
  216. },{"./node_modules/cssify":3}]},{},[1]);