feat(view): show default artboard canvas

This commit is contained in:
syntaxbullet
2026-07-03 10:01:02 +02:00
parent fb0c424745
commit b4f1a149c6
4 changed files with 25 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { useEffect, useRef } from "react";
import { useEffect, useRef, useState } from "react";
import type { AppStore } from "@editor/store";
import type { GlobalPointerConsumer, GlobalWheelConsumer } from "@input/index";
import {
@@ -24,6 +24,7 @@ export function CanvasViewport({
globalWheelConsumer = ignoreGlobalWheel,
}: CanvasViewportProps) {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const [isPanning, setIsPanning] = useState(false);
useEffect(() => {
const canvas = canvasRef.current;
@@ -73,6 +74,7 @@ export function CanvasViewport({
if (!consumed) return;
canvas.setPointerCapture(event.pointerId);
setIsPanning(true);
event.preventDefault();
};
@@ -83,7 +85,10 @@ export function CanvasViewport({
const handlePointerUp = (event: PointerEvent) => {
const consumed = panHandler.pointerUp(pointerInputEventFromPointerEvent(event));
if (consumed) event.preventDefault();
if (!consumed) return;
setIsPanning(false);
event.preventDefault();
};
canvas.addEventListener("pointerdown", handlePointerDown);
@@ -118,5 +123,5 @@ export function CanvasViewport({
return () => canvas.removeEventListener("wheel", handleWheel);
}, [globalWheelConsumer, store]);
return <canvas ref={canvasRef} className="h-full w-full" />;
return <canvas ref={canvasRef} className={isPanning ? "h-full w-full cursor-grabbing" : "h-full w-full cursor-grab"} />;
}