瀏覽代碼

Fix slider dragging on touch devices

gh-pages
Gregor MacLennan 9 年之前
父節點
當前提交
5780b86776
共有 2 個檔案被更改,包括 11 行新增3 行删除
  1. 1
    0
      CHANGELOG.md
  2. 10
    3
      index.js

+ 1
- 0
CHANGELOG.md 查看文件

@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
8 8
 - ADDED: Add `setLeftLayers()` and `setRightLayers()` methods
9 9
 - ADDED: `options.padding`
10 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 13
 ## [v1.1.1] - 2015-12-03
13 14
 

+ 10
- 3
index.js 查看文件

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

Loading…
取消
儲存