[Editor] Make editors draggable with touchscreens
This commit is contained in:
parent
7769018316
commit
b8aab5d14e
@ -68,6 +68,10 @@ class AnnotationEditor {
|
|||||||
|
|
||||||
#moveInDOMTimeout = null;
|
#moveInDOMTimeout = null;
|
||||||
|
|
||||||
|
#prevDragX = 0;
|
||||||
|
|
||||||
|
#prevDragY = 0;
|
||||||
|
|
||||||
_initialOptions = Object.create(null);
|
_initialOptions = Object.create(null);
|
||||||
|
|
||||||
_uiManager = null;
|
_uiManager = null;
|
||||||
@ -1035,9 +1039,18 @@ class AnnotationEditor {
|
|||||||
|
|
||||||
let pointerMoveOptions, pointerMoveCallback;
|
let pointerMoveOptions, pointerMoveCallback;
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
|
this.div.classList.add("moving");
|
||||||
pointerMoveOptions = { passive: true, capture: true };
|
pointerMoveOptions = { passive: true, capture: true };
|
||||||
|
this.#prevDragX = event.clientX;
|
||||||
|
this.#prevDragY = event.clientY;
|
||||||
pointerMoveCallback = e => {
|
pointerMoveCallback = e => {
|
||||||
const [tx, ty] = this.screenToPageTranslation(e.movementX, e.movementY);
|
const { clientX: x, clientY: y } = e;
|
||||||
|
const [tx, ty] = this.screenToPageTranslation(
|
||||||
|
x - this.#prevDragX,
|
||||||
|
y - this.#prevDragY
|
||||||
|
);
|
||||||
|
this.#prevDragX = x;
|
||||||
|
this.#prevDragY = y;
|
||||||
this._uiManager.dragSelectedEditors(tx, ty);
|
this._uiManager.dragSelectedEditors(tx, ty);
|
||||||
};
|
};
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
@ -1051,6 +1064,7 @@ class AnnotationEditor {
|
|||||||
window.removeEventListener("pointerup", pointerUpCallback);
|
window.removeEventListener("pointerup", pointerUpCallback);
|
||||||
window.removeEventListener("blur", pointerUpCallback);
|
window.removeEventListener("blur", pointerUpCallback);
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
|
this.div.classList.remove("moving");
|
||||||
window.removeEventListener(
|
window.removeEventListener(
|
||||||
"pointermove",
|
"pointermove",
|
||||||
pointerMoveCallback,
|
pointerMoveCallback,
|
||||||
|
@ -121,6 +121,10 @@
|
|||||||
cursor: move;
|
cursor: move;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.moving {
|
||||||
|
touch-action: none;
|
||||||
|
}
|
||||||
|
|
||||||
&.selectedEditor {
|
&.selectedEditor {
|
||||||
border: var(--focus-outline);
|
border: var(--focus-outline);
|
||||||
outline: var(--focus-outline-around);
|
outline: var(--focus-outline-around);
|
||||||
|
Loading…
Reference in New Issue
Block a user