Skip to content

Commit 373ccb1

Browse files
danielbarelagmaclennan
authored andcommitted
Determine correct event
only repsond to one event on machines that can handle touch and mouse events
1 parent 09a0d76 commit 373ccb1

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,17 @@ L.Control.SideBySide = L.Control.extend({
174174
map.on('move', this._updateClip, this)
175175
map.on('layeradd layerremove', this._updateLayers, this)
176176
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)
179179
},
180180

181181
_removeEvents: function () {
182182
var range = this._range
183183
var map = this._map
184184
if (range) {
185185
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)
188188
}
189189
if (map) {
190190
map.off('layeradd layerremove', this._updateLayers, this)

leaflet-side-by-side.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,17 @@ L.Control.SideBySide = L.Control.extend({
176176
map.on('move', this._updateClip, this)
177177
map.on('layeradd layerremove', this._updateLayers, this)
178178
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)
181181
},
182182

183183
_removeEvents: function () {
184184
var range = this._range
185185
var map = this._map
186186
if (range) {
187187
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)
190190
}
191191
if (map) {
192192
map.off('layeradd layerremove', this._updateLayers, this)

leaflet-side-by-side.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)