Browse Source

Determine correct event

only repsond to one event on machines that can handle touch and mouse events
gh-pages
Dan Barela 7 years ago
parent
commit
373ccb1178
3 changed files with 9 additions and 9 deletions
  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 View File

174
     map.on('move', this._updateClip, this)
174
     map.on('move', this._updateClip, this)
175
     map.on('layeradd layerremove', this._updateLayers, this)
175
     map.on('layeradd layerremove', this._updateLayers, this)
176
     on(range, getRangeEvent(range), this._updateClip, this)
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
   _removeEvents: function () {
181
   _removeEvents: function () {
183
     var map = this._map
183
     var map = this._map
184
     if (range) {
184
     if (range) {
185
       off(range, getRangeEvent(range), this._updateClip, this)
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
     if (map) {
189
     if (map) {
190
       map.off('layeradd layerremove', this._updateLayers, this)
190
       map.off('layeradd layerremove', this._updateLayers, this)

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

176
     map.on('move', this._updateClip, this)
176
     map.on('move', this._updateClip, this)
177
     map.on('layeradd layerremove', this._updateLayers, this)
177
     map.on('layeradd layerremove', this._updateLayers, this)
178
     on(range, getRangeEvent(range), this._updateClip, this)
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
   _removeEvents: function () {
183
   _removeEvents: function () {
185
     var map = this._map
185
     var map = this._map
186
     if (range) {
186
     if (range) {
187
       off(range, getRangeEvent(range), this._updateClip, this)
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
     if (map) {
191
     if (map) {
192
       map.off('layeradd layerremove', this._updateLayers, this)
192
       map.off('layeradd layerremove', this._updateLayers, this)

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


Loading…
Cancel
Save