Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

leaflet-side-by-side.js 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. // Leaflet v0.7 backwards compatibility
  8. function on (el, types, fn, context) {
  9. types.split(' ').forEach(function (type) {
  10. L.DomEvent.on(el, type, fn, context)
  11. })
  12. }
  13. function off (el, types, fn, context) {
  14. types.split(' ').forEach(function (type) {
  15. L.DomEvent.off(el, type, fn, context)
  16. })
  17. }
  18. function getRangeEvent (rangeInput) {
  19. return 'oninput' in rangeInput ? 'input' : 'change'
  20. }
  21. function cancelMapDrag () {
  22. mapWasDragEnabled = this._map.dragging.enabled()
  23. this._map.dragging.disable()
  24. }
  25. function uncancelMapDrag (e) {
  26. if (!mapWasDragEnabled) return
  27. this._refocusOnMap(e)
  28. this._map.dragging.enable()
  29. }
  30. function noop () {
  31. return
  32. }
  33. L.Control.SideBySide = L.Control.extend({
  34. initialize: function (leftLayers, rightLayers) {
  35. this._leftLayers = Array.isArray(leftLayers) ? leftLayers : [leftLayers]
  36. this._rightLayers = Array.isArray(rightLayers) ? rightLayers : [rightLayers]
  37. },
  38. getPosition: noop,
  39. setPosition: noop,
  40. addTo: function (map) {
  41. this.remove()
  42. this._map = map
  43. var container = this._container = L.DomUtil.create('div', 'leaflet-sbs', map._controlContainer)
  44. this._divider = L.DomUtil.create('div', 'leaflet-sbs-divider', container)
  45. var range = this._range = L.DomUtil.create('input', 'leaflet-sbs-range', container)
  46. range.type = 'range'
  47. range.min = 0
  48. range.max = 1
  49. range.step = 'any'
  50. this._addEvents()
  51. this._updateLayers()
  52. this._updateClip()
  53. return this
  54. },
  55. remove: function () {
  56. if (!this._map) {
  57. return this
  58. }
  59. this._removeEvents()
  60. L.DomUtil.remove(this._container)
  61. this._map = null
  62. return this
  63. },
  64. _updateClip: function () {
  65. var map = this._map
  66. var rangeValue = this._range.value
  67. var nw = map.containerPointToLayerPoint([0, 0])
  68. var se = map.containerPointToLayerPoint(map.getSize())
  69. var offset = (0.5 - rangeValue) * 44
  70. var clipX = nw.x + (se.x - nw.x) * rangeValue + offset
  71. this._divider.style.left = map.getSize().x * rangeValue + offset + 'px'
  72. var clipLeft = 'rect(' + [nw.y, clipX, se.y, nw.x].join('px,') + 'px)'
  73. var clipRight = 'rect(' + [nw.y, se.x, se.y, clipX].join('px,') + 'px)'
  74. if (this._leftLayer) {
  75. this._leftLayer.getContainer().style.clip = clipLeft
  76. }
  77. if (this._rightLayer) {
  78. this._rightLayer.getContainer().style.clip = clipRight
  79. }
  80. },
  81. _updateLayers: function () {
  82. this._leftLayer = this._rightLayer = null
  83. this._leftLayers.forEach(function (layer) {
  84. if (this._map.hasLayer(layer)) this._leftLayer = layer
  85. }, this)
  86. this._rightLayers.forEach(function (layer) {
  87. if (this._map.hasLayer(layer)) this._rightLayer = layer
  88. }, this)
  89. this._updateClip()
  90. },
  91. _addEvents: function () {
  92. var range = this._range
  93. var map = this._map
  94. if (!map || !range) return
  95. map.on('move', this._updateClip, this)
  96. map.on('layeradd layerremove', this._updateLayers, this)
  97. on(range, getRangeEvent(range), this._updateClip, this)
  98. on(range, 'mousedown touchstart', cancelMapDrag, this)
  99. on(range, 'mouseup touchend', uncancelMapDrag, this)
  100. },
  101. _removeEvents: function () {
  102. var range = this._range
  103. var map = this._map
  104. if (range) {
  105. off(range, getRangeEvent(range), this._updateClip, this)
  106. off(range, 'mousedown touchstart', cancelMapDrag, this)
  107. off(range, 'mouseup touchend', uncancelMapDrag, this)
  108. }
  109. if (map) {
  110. map.off('layeradd layerremove', this._updateLayers, this)
  111. map.off('move', this._updateClip, this)
  112. }
  113. }
  114. })
  115. L.Control.sideBySide = function (leftLayers, rightLayers, options) {
  116. return new L.Control.SideBySide(leftLayers, rightLayers, options)
  117. }
  118. module.export = L.Control.sideBySide
  119. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  120. },{"./layout.css":2,"./range.css":4}],2:[function(require,module,exports){
  121. 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;
  122. },{"./node_modules/cssify":3}],3:[function(require,module,exports){
  123. function injectStyleTag(document, fileName, cb) {
  124. var style = document.getElementById(fileName);
  125. if (style) {
  126. cb(style);
  127. } else {
  128. var head = document.getElementsByTagName('head')[0];
  129. style = document.createElement('style');
  130. style.id = fileName;
  131. cb(style);
  132. head.appendChild(style);
  133. }
  134. return style;
  135. }
  136. module.exports = function (css, customDocument, fileName) {
  137. var doc = customDocument || document;
  138. if (doc.createStyleSheet) {
  139. var sheet = doc.createStyleSheet()
  140. sheet.cssText = css;
  141. return sheet.ownerNode;
  142. } else {
  143. return injectStyleTag(doc, fileName, function(style) {
  144. if (style.styleSheet) {
  145. style.styleSheet.cssText = css;
  146. } else {
  147. style.innerHTML = css;
  148. }
  149. });
  150. }
  151. };
  152. module.exports.byUrl = function(url) {
  153. if (document.createStyleSheet) {
  154. return document.createStyleSheet(url).ownerNode;
  155. } else {
  156. var head = document.getElementsByTagName('head')[0],
  157. link = document.createElement('link');
  158. link.rel = 'stylesheet';
  159. link.href = url;
  160. head.appendChild(link);
  161. return link;
  162. }
  163. };
  164. },{}],4:[function(require,module,exports){
  165. 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;
  166. },{"./node_modules/cssify":3}]},{},[1]);