mirror of
https://github.com/motion-canvas/motion-canvas.git
synced 2026-01-11 14:57:56 -05:00
feat: pan with shift and left click (#7)
Add another way to pan the view for trackpad users. Closes #5
This commit is contained in:
@@ -52,7 +52,7 @@ export function View() {
|
||||
[setState, state],
|
||||
),
|
||||
undefined,
|
||||
1,
|
||||
null,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -131,7 +131,7 @@ export function View() {
|
||||
className={styles.viewport}
|
||||
ref={containerRef}
|
||||
onMouseDown={event => {
|
||||
if (event.button === 0) {
|
||||
if (event.button === 0 && !event.shiftKey) {
|
||||
const position = {
|
||||
x: event.x - size.x,
|
||||
y: event.y - size.y,
|
||||
|
||||
@@ -12,7 +12,7 @@ interface DropCallback {
|
||||
export function useDrag(
|
||||
onMove: MoveCallback,
|
||||
onDrop?: DropCallback,
|
||||
button = 0,
|
||||
button: number | null = 0,
|
||||
): [(event: MouseEvent) => void, boolean] {
|
||||
const [isDragging, setDragging] = useState(false);
|
||||
const [startPosition, setStartPosition] = useState({x: 0, y: 0});
|
||||
@@ -51,7 +51,7 @@ export function useDrag(
|
||||
|
||||
const handleDrag = useCallback(
|
||||
(event: MouseEvent) => {
|
||||
if (event.button !== button) return;
|
||||
if (button !== null && event.button !== button) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setStartPosition({x: event.x, y: event.y});
|
||||
|
||||
Reference in New Issue
Block a user