Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

leaflet-side-by-side.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. if (this._leftLayer) {
  83. this._leftLayer.getContainer().style.clip = ""
  84. }
  85. if (this._rightLayer) {
  86. this._rightLayer.getContainer().style.clip = ""
  87. }
  88. this._removeEvents()
  89. L.DomUtil.remove(this._container)
  90. this._map = null
  91. return this
  92. },
  93. setLeftLayers: function (leftLayers) {
  94. this._leftLayers = asArray(leftLayers)
  95. this._updateLayers()
  96. return this
  97. },
  98. setRightLayers: function (rightLayers) {
  99. this._rightLayers = asArray(rightLayers)
  100. this._updateLayers()
  101. return this
  102. },
  103. _updateClip: function () {
  104. var map = this._map
  105. var nw = map.containerPointToLayerPoint([0, 0])
  106. var se = map.containerPointToLayerPoint(map.getSize())
  107. var clipX = nw.x + this.getPosition()
  108. var dividerX = this.getPosition()
  109. this._divider.style.left = dividerX + 'px'
  110. this.fire('dividermove', {x: dividerX})
  111. var clipLeft = 'rect(' + [nw.y, clipX, se.y, nw.x].join('px,') + 'px)'
  112. var clipRight = 'rect(' + [nw.y, se.x, se.y, clipX].join('px,') + 'px)'
  113. if (this._leftLayer) {
  114. this._leftLayer.getContainer().style.clip = clipLeft
  115. }
  116. if (this._rightLayer) {
  117. this._rightLayer.getContainer().style.clip = clipRight
  118. }
  119. },
  120. _updateLayers: function () {
  121. if (!this._map) {
  122. return this
  123. }
  124. var prevLeft = this._leftLayer
  125. var prevRight = this._rightLayer
  126. this._leftLayer = this._rightLayer = null
  127. this._leftLayers.forEach(function (layer) {
  128. if (this._map.hasLayer(layer)) {
  129. this._leftLayer = layer
  130. }
  131. }, this)
  132. this._rightLayers.forEach(function (layer) {
  133. if (this._map.hasLayer(layer)) {
  134. this._rightLayer = layer
  135. }
  136. }, this)
  137. if (prevLeft !== this._leftLayer) {
  138. prevLeft && this.fire('leftlayerremove', {layer: prevLeft})
  139. this._leftLayer && this.fire('leftlayeradd', {layer: this._leftLayer})
  140. }
  141. if (prevRight !== this._rightLayer) {
  142. prevRight && this.fire('rightlayerremove', {layer: prevRight})
  143. this._rightLayer && this.fire('rightlayeradd', {layer: this._rightLayer})
  144. }
  145. this._updateClip()
  146. },
  147. _addEvents: function () {
  148. var range = this._range
  149. var map = this._map
  150. if (!map || !range) return
  151. map.on('move', this._updateClip, this)
  152. map.on('layeradd layerremove', this._updateLayers, this)
  153. on(range, getRangeEvent(range), this._updateClip, this)
  154. on(range, L.Browser.touch ? 'touchstart' : 'mousedown', cancelMapDrag, this)
  155. on(range, L.Browser.touch ? 'touchend' : 'mouseup', uncancelMapDrag, this)
  156. },
  157. _removeEvents: function () {
  158. var range = this._range
  159. var map = this._map
  160. if (range) {
  161. off(range, getRangeEvent(range), this._updateClip, this)
  162. off(range, L.Browser.touch ? 'touchstart' : 'mousedown', cancelMapDrag, this)
  163. off(range, L.Browser.touch ? 'touchend' : 'mouseup', uncancelMapDrag, this)
  164. }
  165. if (map) {
  166. map.off('layeradd layerremove', this._updateLayers, this)
  167. map.off('move', this._updateClip, this)
  168. }
  169. }
  170. })
  171. L.control.sideBySide = function (leftLayers, rightLayers, options) {
  172. return new L.Control.SideBySide(leftLayers, rightLayers, options)
  173. }
  174. module.exports = L.Control.SideBySide
  175. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  176. },{"./layout.css":2,"./range.css":4}],2:[function(require,module,exports){
  177. 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, '/data/github/leaflet-side-by-side/layout.css'); module.exports = css;
  178. },{"./node_modules/cssify":3}],3:[function(require,module,exports){
  179. function injectStyleTag(document, fileName, cb) {
  180. var style = document.getElementById(fileName);
  181. if (style) {
  182. cb(style);
  183. } else {
  184. var head = document.getElementsByTagName('head')[0];
  185. style = document.createElement('style');
  186. style.id = fileName;
  187. cb(style);
  188. head.appendChild(style);
  189. }
  190. return style;
  191. }
  192. module.exports = function (css, customDocument, fileName) {
  193. var doc = customDocument || document;
  194. if (doc.createStyleSheet) {
  195. var sheet = doc.createStyleSheet()
  196. sheet.cssText = css;
  197. return sheet.ownerNode;
  198. } else {
  199. return injectStyleTag(doc, fileName, function(style) {
  200. if (style.styleSheet) {
  201. style.styleSheet.cssText = css;
  202. } else {
  203. style.innerHTML = css;
  204. }
  205. });
  206. }
  207. };
  208. module.exports.byUrl = function(url) {
  209. if (document.createStyleSheet) {
  210. return document.createStyleSheet(url).ownerNode;
  211. } else {
  212. var head = document.getElementsByTagName('head')[0],
  213. link = document.createElement('link');
  214. link.rel = 'stylesheet';
  215. link.href = url;
  216. head.appendChild(link);
  217. return link;
  218. }
  219. };
  220. },{}],4:[function(require,module,exports){
  221. 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, '/data/github/leaflet-side-by-side/range.css'); module.exports = css;
  222. },{"./node_modules/cssify":3}]},{},[1]);