Commit 12ad3793 authored by Ujvari Gergely's avatar Ujvari Gergely

Fix for #305

- The drag events were not ported to jschannel.
- Incorporated fix (updated to the current HEAD) for issue #262 too
parent d2561e81
......@@ -14,6 +14,8 @@ class Annotator.Host extends Annotator
delta: 0
last: null
tick: false
#Do we enable dragging
canDrag: false
constructor: (element, options) ->
super
......@@ -141,6 +143,10 @@ class Annotator.Host extends Annotator
$('html, body').stop().animate {scrollTop: y}, 600
)
.bind('setDrag', (ctx, drag) =>
@canDrag = drag
)
scanDocument: (reason = "something happened") =>
try
console.log "Analyzing host frame, because " + reason + "..."
......@@ -190,6 +196,7 @@ 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'
......@@ -202,6 +209,7 @@ class Annotator.Host extends Annotator
@drag.tick = true
window.requestAnimationFrame this._dragRefresh
document.addEventListener 'dragleave', (event) =>
unless @canDrag then return
if @drag.last?
@drag.delta += event.screenX - @drag.last
@drag.last = event.screenX
......
......@@ -15,6 +15,7 @@ class Hypothesis extends Annotator
# Internal state
visible: false # * Whether the sidebar is visible
dragging: false # * To enable dragging only when we really want to
# Here as a noop just to make the Permissions plugin happy
# XXX: Change me when Annotator stops assuming things about viewers
......@@ -191,13 +192,17 @@ class Hypothesis extends Annotator
handle.addEventListener 'dragstart', (event) =>
event.dataTransfer.setData 'text/plain', ''
event.dataTransfer.setDragImage el, 0, 0
@provider.dragFrame event.screenX
@dragging = true
@provider.notify method: 'setDrag', params: true
@provider.notify method: 'dragFrame', params: event.screenX
handle.addEventListener 'dragend', (event) =>
@provider.dragFrame event.screenX
@dragging = false
@provider.notify method: 'setDrag', params: false
@provider.notify method: 'dragFrame', params: event.screenX
@element[0].addEventListener 'dragover', (event) =>
@provider.dragFrame event.screenX
if @dragging then @provider.notify method: 'dragFrame', params: event.screenX
@element[0].addEventListener 'dragleave', (event) =>
@provider.dragFrame event.screenX
if @dragging then @provider.notify method: 'dragFrame', params: event.screenX
this
......
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