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
icon={
<svg
@ -50,10 +51,10 @@ function App() {
</g>
</svg>
}
onClick={() => {
setFile(undefined)
}}
/>
) : (
<></>
)}
</header>
<main

View File

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