Skip to content

Commit 88bd396

Browse files
committed
feat: update
1 parent dadfafd commit 88bd396

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/drage.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class DrageJs {
4646

4747
this.ref && this.ref.setAttribute('draggable', false)
4848

49-
this.ref && this.ref.addEventListener('touchstart', _ => this.onStart(_, this))
50-
this.ref && this.ref.addEventListener('mousedown', _ => this.onStart(_, this))
49+
this.ref && this.ref.addEventListener('touchstart', _ => this.onStart(_, this), {passive: false})
50+
this.ref && this.ref.addEventListener('mousedown', _ => this.onStart(_, this), {passive: false})
5151

5252
document.addEventListener('touchend', _ => this.onEnd(_, this))
5353
document.addEventListener('mouseup', _ => this.onEnd(_, this))
@@ -105,6 +105,8 @@ class DrageJs {
105105
}
106106

107107
onStart(event, _this) {
108+
event.preventDefault()
109+
108110
_this.draggingFlag = true
109111

110112
let _event = event.type === 'mousedown' ? event : event.changedTouches && event.changedTouches[0]
@@ -116,7 +118,6 @@ class DrageJs {
116118

117119
document.addEventListener('touchmove', _ => _this.onMove(_, _this), {passive: false})
118120
document.addEventListener('mousemove', _ => _this.onMove(_, _this), {passive: false})
119-
document.addEventListener('mouseleave', _ => _this.onEnd(_, _this), {passive: false})
120121
}
121122

122123
onMove(event, _this) {

0 commit comments

Comments
 (0)