Commit 4c3a4b55 authored by Randall Leeds's avatar Randall Leeds

fix up some drag event issues

- Change `drag.canDrag` to `drag.enabled`
- Track when dragging ends to reset the delta measure point
- Remove dragstart event which won't fire in the host
parent c575e5ae
......@@ -12,10 +12,9 @@ class Annotator.Host extends Annotator
# Drag state variables
drag:
delta: 0
enabled: false
last: null
tick: false
#Do we enable dragging
canDrag: false
constructor: (element, options) ->
super
......@@ -155,7 +154,8 @@ class Annotator.Host extends Annotator
)
.bind('setDrag', (ctx, drag) =>
@canDrag = drag
@drag.enabled = drag
@drag.last = null
)
scanDocument: (reason = "something happened") =>
......@@ -207,21 +207,12 @@ class Annotator.Host extends Annotator
@panel?.notify method: 'publish', params: 'hostUpdated'
document.addEventListener 'touchmove', update
document.addEventListener 'touchstart', =>
unless @canDrag then return
touch = true
@frame?.css
display: 'none'
do update
document.addEventListener 'dragover', (event) =>
unless @canDrag then return
if @drag.last?
@drag.delta += event.screenX - @drag.last
@drag.last = event.screenX
unless @drag.tick
@drag.tick = true
window.requestAnimationFrame this._dragRefresh
document.addEventListener 'dragleave', (event) =>
unless @canDrag then return
unless @drag.enabled then return
if @drag.last?
@drag.delta += event.screenX - @drag.last
@drag.last = event.screenX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment