Skip to content

Commit

Permalink
Merge pull request #190 from blms/blms/movehandler
Browse files Browse the repository at this point in the history
Simplify moveHandler (#186)
  • Loading branch information
rsimon authored Jan 17, 2024
2 parents abadeae + 2d01e81 commit d5df4ba
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/OSDAnnotationLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,18 @@ export class AnnotationLayer extends EventEmitter {
if (this.tools.current.isDrawing) {
const { x , y } = this.tools.current.getSVGPoint(evt.originalEvent);

if (!evt.buttons || !firstDragDone) {
if (!firstDragDone) {
evt.originalEvent.stopPropagation();
}

this.tools.current.onMouseMove(x, y, evt.originalEvent);
this.tools.current.onMouseMove(x, y, evt.originalEvent);

if (!started) {
this.emit('startSelection', { x , y });
started = true;
}
} else {
if (!dragging && this.tools.current.onDragStart)
this.tools.current.onDragStart(x, y, evt.originalEvent);
if (!started) {
this.emit('startSelection', { x , y });
started = true;
}
if (!dragging && this.tools.current.onDragStart) {
this.tools.current.onDragStart(x, y, evt.originalEvent);

dragging = true;
}
Expand All @@ -199,12 +199,13 @@ export class AnnotationLayer extends EventEmitter {

releaseHandler: evt => {
if (this.tools.current.isDrawing) {
firstDragDone = true;

// continue in dragging mode if moveHandler has not been fired
// if (!started) return;
const { x , y } = this.tools.current.getSVGPoint(evt.originalEvent);
if (started) this.emit('endSelection', { x , y });
if (started) {
this.emit('endSelection', { x , y });
firstDragDone = true;
}
this.tools.current.onMouseUp(x, y, evt.originalEvent);

if (dragging && this.tools.current.onDragEnd)
Expand Down Expand Up @@ -246,7 +247,6 @@ export class AnnotationLayer extends EventEmitter {
if (evt.key.toLowerCase() === hotkey && !this.tools.current.isDrawing) {
this.mouseTracker.enabled = inverted;
this.tools.current.enabled = inverted;

firstDragDone = false;
}
};
Expand Down

0 comments on commit d5df4ba

Please sign in to comment.