Kaynağa Gözat

Determine correct event

only repsond to one event on machines that can handle touch and mouse events
gh-pages
Dan Barela 7 yıl önce
ebeveyn
işleme
373ccb1178
3 değiştirilmiş dosya ile 9 ekleme ve 9 silme
  1. 4
    4
      index.js
  2. 4
    4
      leaflet-side-by-side.js
  3. 1
    1
      leaflet-side-by-side.min.js

+ 4
- 4
index.js Dosyayı Görüntüle

@@ -174,8 +174,8 @@ L.Control.SideBySide = L.Control.extend({
174 174
     map.on('move', this._updateClip, this)
175 175
     map.on('layeradd layerremove', this._updateLayers, this)
176 176
     on(range, getRangeEvent(range), this._updateClip, this)
177
-    on(range, 'mousedown touchstart', cancelMapDrag, this)
178
-    on(range, 'mouseup touchend', uncancelMapDrag, this)
177
+    on(range, L.Browser.touch ? 'touchstart' : 'mousedown', cancelMapDrag, this)
178
+    on(range, L.Browser.touch ? 'touchend' : 'mouseup', uncancelMapDrag, this)
179 179
   },
180 180
 
181 181
   _removeEvents: function () {
@@ -183,8 +183,8 @@ L.Control.SideBySide = L.Control.extend({
183 183
     var map = this._map
184 184
     if (range) {
185 185
       off(range, getRangeEvent(range), this._updateClip, this)
186
-      off(range, 'mousedown touchstart', cancelMapDrag, this)
187
-      off(range, 'mouseup touchend', uncancelMapDrag, this)
186
+      off(range, L.Browser.touch ? 'touchstart' : 'mousedown', cancelMapDrag, this)
187
+      off(range, L.Browser.touch ? 'touchend' : 'mouseup', uncancelMapDrag, this)
188 188
     }
189 189
     if (map) {
190 190
       map.off('layeradd layerremove', this._updateLayers, this)

+ 4
- 4
leaflet-side-by-side.js Dosyayı Görüntüle

@@ -176,8 +176,8 @@ L.Control.SideBySide = L.Control.extend({
176 176
     map.on('move', this._updateClip, this)
177 177
     map.on('layeradd layerremove', this._updateLayers, this)
178 178
     on(range, getRangeEvent(range), this._updateClip, this)
179
-    on(range, 'mousedown touchstart', cancelMapDrag, this)
180
-    on(range, 'mouseup touchend', uncancelMapDrag, this)
179
+    on(range, L.Browser.touch ? 'touchstart' : 'mousedown', cancelMapDrag, this)
180
+    on(range, L.Browser.touch ? 'touchend' : 'mouseup', uncancelMapDrag, this)
181 181
   },
182 182
 
183 183
   _removeEvents: function () {
@@ -185,8 +185,8 @@ L.Control.SideBySide = L.Control.extend({
185 185
     var map = this._map
186 186
     if (range) {
187 187
       off(range, getRangeEvent(range), this._updateClip, this)
188
-      off(range, 'mousedown touchstart', cancelMapDrag, this)
189
-      off(range, 'mouseup touchend', uncancelMapDrag, this)
188
+      off(range, L.Browser.touch ? 'touchstart' : 'mousedown', cancelMapDrag, this)
189
+      off(range, L.Browser.touch ? 'touchend' : 'mouseup', uncancelMapDrag, this)
190 190
     }
191 191
     if (map) {
192 192
       map.off('layeradd layerremove', this._updateLayers, this)

+ 1
- 1
leaflet-side-by-side.min.js
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


Loading…
İptal
Kaydet