-
-
Save tomhicks/64d6d76bddffdd5743a021e9c992de76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mode: "idle" | "dragging" = "idle" | |
const dragHandler: InteractionHandler = { | |
onDragStart(gesture, app) { | |
if (intersection(gesture.elementsUnderCursor, app.selectedElements).size) { | |
mode = "dragging"; | |
} | |
}, | |
onPointerMove(gesture) { | |
// ignore pointer-moves when we haven't started dragging | |
if (mode !== "dragging") return; | |
const delta = sub(gesture.current.point, gesture.start.point); | |
transformSelectedElements(delta) | |
// prevents other pointermove handlers acting (not important for this case) | |
gesture.wasHandled(); | |
}, | |
onDragEnd() { | |
mode = "idle"; | |
}, | |
}; | |
const selectionHandler: InteractionHandler = { | |
onClick(gesture) { | |
addElementToSelectionSet(gesture.topElement); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment