Browse Source

1.1.1

gh-pages
Gregor MacLennan 9 years ago
parent
commit
cc70aab699
4 changed files with 33 additions and 12 deletions
  1. 7
    6
      CHANGELOG.md
  2. 24
    4
      leaflet-side-by-side.js
  3. 1
    1
      leaflet-side-by-side.min.js
  4. 1
    1
      package.json

+ 7
- 6
CHANGELOG.md View File

@@ -3,14 +3,15 @@
3 3
 All notable changes to this project will be documented in this file.
4 4
 This project adheres to [Semantic Versioning](http://semver.org/).
5 5
 
6
-## [1.1.0] - 2015-12-03
6
+## v1.1.1
7 7
 
8
-### Added
9
-- Events
8
+- FIXED: fix package.json settings for npm distribution
10 9
 
11
-### Fixed
12
-- Fix initial divider position in Firefox, should start in middle of map
10
+## v1.1.0 - 2015-12-03
13 11
 
14
-## [1.0.2] - 2015-12-02
12
+- ADDED: Events
13
+- FIXED: Fix initial divider position in Firefox, should start in middle of map
14
+
15
+## v1.0.2 - 2015-12-02
15 16
 
16 17
 Initial release

+ 24
- 4
leaflet-side-by-side.js View File

@@ -13,6 +13,7 @@ function on (el, types, fn, context) {
13 13
   })
14 14
 }
15 15
 
16
+// Leaflet v0.7 backwards compatibility
16 17
 function off (el, types, fn, context) {
17 18
   types.split(' ').forEach(function (type) {
18 19
     L.DomEvent.off(el, type, fn, context)
@@ -48,6 +49,8 @@ L.Control.SideBySide = L.Control.extend({
48 49
 
49 50
   setPosition: noop,
50 51
 
52
+  includes: L.Mixin.Events,
53
+
51 54
   addTo: function (map) {
52 55
     this.remove()
53 56
     this._map = map
@@ -60,6 +63,7 @@ L.Control.SideBySide = L.Control.extend({
60 63
     range.min = 0
61 64
     range.max = 1
62 65
     range.step = 'any'
66
+    range.value = 0.5
63 67
     this._addEvents()
64 68
     this._updateLayers()
65 69
     this._updateClip()
@@ -85,8 +89,10 @@ L.Control.SideBySide = L.Control.extend({
85 89
     var se = map.containerPointToLayerPoint(map.getSize())
86 90
     var offset = (0.5 - rangeValue) * 44
87 91
     var clipX = nw.x + (se.x - nw.x) * rangeValue + offset
92
+    var dividerX = map.getSize().x * rangeValue + offset
88 93
 
89
-    this._divider.style.left = map.getSize().x * rangeValue + offset + 'px'
94
+    this._divider.style.left = dividerX + 'px'
95
+    this.fire('dividermove', {x: dividerX})
90 96
     var clipLeft = 'rect(' + [nw.y, clipX, se.y, nw.x].join('px,') + 'px)'
91 97
     var clipRight = 'rect(' + [nw.y, se.x, se.y, clipX].join('px,') + 'px)'
92 98
     if (this._leftLayer) {
@@ -98,13 +104,27 @@ L.Control.SideBySide = L.Control.extend({
98 104
   },
99 105
 
100 106
   _updateLayers: function () {
107
+    var prevLeft = this._leftLayer
108
+    var prevRight = this._rightLayer
101 109
     this._leftLayer = this._rightLayer = null
102 110
     this._leftLayers.forEach(function (layer) {
103
-      if (this._map.hasLayer(layer)) this._leftLayer = layer
111
+      if (this._map.hasLayer(layer)) {
112
+        this._leftLayer = layer
113
+      }
104 114
     }, this)
105 115
     this._rightLayers.forEach(function (layer) {
106
-      if (this._map.hasLayer(layer)) this._rightLayer = layer
116
+      if (this._map.hasLayer(layer)) {
117
+        this._rightLayer = layer
118
+      }
107 119
     }, this)
120
+    if (prevLeft !== this._leftLayer) {
121
+      prevLeft && this.fire('leftlayerremove', {layer: prevLeft})
122
+      this._leftLayer && this.fire('leftlayeradd', {layer: this._leftLayer})
123
+    }
124
+    if (prevRight !== this._rightLayer) {
125
+      prevRight && this.fire('rightlayerremove', {layer: prevRight})
126
+      this._rightLayer && this.fire('rightlayeradd', {layer: this._rightLayer})
127
+    }
108 128
     this._updateClip()
109 129
   },
110 130
 
@@ -194,5 +214,5 @@ module.exports.byUrl = function(url) {
194 214
 };
195 215
 
196 216
 },{}],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;
217
+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;
198 218
 },{"./node_modules/cssify":3}]},{},[1]);

+ 1
- 1
leaflet-side-by-side.min.js
File diff suppressed because it is too large
View File


+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "leaflet-side-by-side",
3
-  "version": "1.1.0",
3
+  "version": "1.1.1",
4 4
   "description": "Compare two Leaflet layers side by side",
5 5
   "main": "index.js",
6 6
   "files": [

Loading…
Cancel
Save