Browse Source

Add get position

gh-pages
Gregor MacLennan 9 years ago
parent
commit
074522a69a
2 changed files with 8 additions and 5 deletions
  1. 1
    0
      CHANGELOG.md
  2. 7
    5
      index.js

+ 1
- 0
CHANGELOG.md View File

7
 
7
 
8
 - ADDED: Add `setLeftLayers()` and `setRightLayers()` methods
8
 - ADDED: Add `setLeftLayers()` and `setRightLayers()` methods
9
 - ADDED: `options.padding`
9
 - ADDED: `options.padding`
10
+- ADDED: `getPosition()` returns the x coordinate (relative to the map container) of the divider
10
 - FIXED: **[BREAKING]** Export factory function on `L.control` not `L.Control`
11
 - FIXED: **[BREAKING]** Export factory function on `L.control` not `L.Control`
11
 - FIXED: Slider drag was not working on touch devices
12
 - FIXED: Slider drag was not working on touch devices
12
 
13
 

+ 7
- 5
index.js View File

61
     L.setOptions(this, options)
61
     L.setOptions(this, options)
62
   },
62
   },
63
 
63
 
64
-  getPosition: noop,
64
+  getPosition: function () {
65
+    var rangeValue = this._range.value
66
+    var offset = (0.5 - rangeValue) * (2 * this.options.padding + this.options.thumbSize)
67
+    return this._map.getSize().x * rangeValue + offset
68
+  },
65
 
69
 
66
   setPosition: noop,
70
   setPosition: noop,
67
 
71
 
112
 
116
 
113
   _updateClip: function () {
117
   _updateClip: function () {
114
     var map = this._map
118
     var map = this._map
115
-    var rangeValue = this._range.value
116
     var nw = map.containerPointToLayerPoint([0, 0])
119
     var nw = map.containerPointToLayerPoint([0, 0])
117
     var se = map.containerPointToLayerPoint(map.getSize())
120
     var se = map.containerPointToLayerPoint(map.getSize())
118
-    var offset = (0.5 - rangeValue) * (2 * this.options.padding + this.options.thumbSize)
119
-    var clipX = nw.x + (se.x - nw.x) * rangeValue + offset
120
-    var dividerX = map.getSize().x * rangeValue + offset
121
+    var clipX = nw.x + this.getPosition()
122
+    var dividerX = this.getPosition()
121
 
123
 
122
     this._divider.style.left = dividerX + 'px'
124
     this._divider.style.left = dividerX + 'px'
123
     this.fire('dividermove', {x: dividerX})
125
     this.fire('dividermove', {x: dividerX})

Loading…
Cancel
Save