Browse Source

Fix slider dragging on touch devices

gh-pages
Gregor MacLennan 9 years ago
parent
commit
5780b86776
2 changed files with 11 additions and 3 deletions
  1. 1
    0
      CHANGELOG.md
  2. 10
    3
      index.js

+ 1
- 0
CHANGELOG.md View File

8
 - ADDED: Add `setLeftLayers()` and `setRightLayers()` methods
8
 - ADDED: Add `setLeftLayers()` and `setRightLayers()` methods
9
 - ADDED: `options.padding`
9
 - ADDED: `options.padding`
10
 - FIXED: **[BREAKING]** Export factory function on `L.control` not `L.Control`
10
 - FIXED: **[BREAKING]** Export factory function on `L.control` not `L.Control`
11
+- FIXED: Slider drag was not working on touch devices
11
 
12
 
12
 ## [v1.1.1] - 2015-12-03
13
 ## [v1.1.1] - 2015-12-03
13
 
14
 

+ 10
- 3
index.js View File

3
 require('./range.css')
3
 require('./range.css')
4
 
4
 
5
 var mapWasDragEnabled
5
 var mapWasDragEnabled
6
+var mapWasTapEnabled
6
 
7
 
7
 // Leaflet v0.7 backwards compatibility
8
 // Leaflet v0.7 backwards compatibility
8
 function on (el, types, fn, context) {
9
 function on (el, types, fn, context) {
24
 
25
 
25
 function cancelMapDrag () {
26
 function cancelMapDrag () {
26
   mapWasDragEnabled = this._map.dragging.enabled()
27
   mapWasDragEnabled = this._map.dragging.enabled()
28
+  mapWasTapEnabled = this._map.tap && this._map.tap.enabled()
27
   this._map.dragging.disable()
29
   this._map.dragging.disable()
30
+  this._map.tap && this._map.tap.disable()
28
 }
31
 }
29
 
32
 
30
 function uncancelMapDrag (e) {
33
 function uncancelMapDrag (e) {
31
-  if (!mapWasDragEnabled) return
32
   this._refocusOnMap(e)
34
   this._refocusOnMap(e)
33
-  this._map.dragging.enable()
35
+  if (mapWasDragEnabled) {
36
+    this._map.dragging.enable()
37
+  }
38
+  if (mapWasTapEnabled) {
39
+    this._map.tap.enable()
40
+  }
34
 }
41
 }
35
 
42
 
36
 // convert arg to an array - returns empty array if arg is undefined
43
 // convert arg to an array - returns empty array if arg is undefined
37
-function asArray(arg) {
44
+function asArray (arg) {
38
   return (arg === 'undefined') ? [] : Array.isArray(arg) ? arg : [arg]
45
   return (arg === 'undefined') ? [] : Array.isArray(arg) ? arg : [arg]
39
 }
46
 }
40
 
47
 

Loading…
Cancel
Save