hold space to pan

This commit is contained in:
Sanster 2022-02-06 22:00:46 +08:00
parent e26fddd936
commit c81fc0ecfc
2 changed files with 46 additions and 37 deletions

View File

@ -25,6 +25,7 @@ function App() {
<></> <></>
)} )}
{file ? (
<Button <Button
icon={ icon={
<svg <svg
@ -50,10 +51,10 @@ function App() {
</g> </g>
</svg> </svg>
} }
onClick={() => {
setFile(undefined)
}}
/> />
) : (
<></>
)}
</header> </header>
<main <main

View File

@ -266,7 +266,13 @@ export default function Editor(props: EditorProps) {
{ {
event: 'keydown', event: 'keydown',
}, },
[isDraging, isMultiStrokeKeyPressed] [
isDraging,
isInpaintingLoading,
isMultiStrokeKeyPressed,
resetZoom,
clearDrawing,
]
) )
const onPaint = (px: number, py: number) => { const onPaint = (px: number, py: number) => {
@ -439,18 +445,20 @@ export default function Editor(props: EditorProps) {
}, [showBrush, isPanning]) }, [showBrush, isPanning])
// Toggle clean/zoom tool on spacebar. // Toggle clean/zoom tool on spacebar.
useKey( useKeyPressEvent(
' ', ' ',
ev => { ev => {
ev?.preventDefault() ev?.preventDefault()
ev?.stopPropagation() ev?.stopPropagation()
setShowBrush(!showBrush) setShowBrush(false)
setIsPanning(!isPanning) setIsPanning(true)
}, },
{ ev => {
event: 'keydown', ev?.preventDefault()
}, ev?.stopPropagation()
[isPanning, showBrush] setShowBrush(true)
setIsPanning(false)
}
) )
if (!original || !scale || !minScale) { if (!original || !scale || !minScale) {