kopia lustrzana https://github.com/Tldraw/Tldraw
improves touch events when drawing
rodzic
76a4ccdfcb
commit
2af0d7b3a7
|
@ -18,10 +18,10 @@ export default function Page() {
|
||||||
const isSelecting = useSelector((s) => s.isIn('selecting'))
|
const isSelecting = useSelector((s) => s.isIn('selecting'))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<g pointerEvents={isSelecting ? 'all' : 'none'}>
|
||||||
{currentPageShapeIds.map((shapeId) => (
|
{currentPageShapeIds.map((shapeId) => (
|
||||||
<Shape key={shapeId} id={shapeId} isSelecting={isSelecting} />
|
<Shape key={shapeId} id={shapeId} isSelecting={isSelecting} />
|
||||||
))}
|
))}
|
||||||
</>
|
</g>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,10 @@ export function ShapeOutline({ id }: { id: string }) {
|
||||||
if (!shape) return null
|
if (!shape) return null
|
||||||
|
|
||||||
const transform = `
|
const transform = `
|
||||||
rotate(${shape.rotation * (180 / Math.PI)},
|
rotate(${shape.rotation * (180 / Math.PI)},
|
||||||
${getShapeUtils(shape).getCenter(shape)})
|
${getShapeUtils(shape).getCenter(shape)})
|
||||||
translate(${shape.point})`
|
translate(${shape.point})
|
||||||
|
`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Indicator
|
<Indicator
|
||||||
|
|
|
@ -8,7 +8,6 @@ import getStroke from 'perfect-freehand'
|
||||||
import {
|
import {
|
||||||
getBoundsCenter,
|
getBoundsCenter,
|
||||||
getBoundsFromPoints,
|
getBoundsFromPoints,
|
||||||
getRotatedCorners,
|
|
||||||
getSvgPathFromStroke,
|
getSvgPathFromStroke,
|
||||||
translateBounds,
|
translateBounds,
|
||||||
} from 'utils/utils'
|
} from 'utils/utils'
|
||||||
|
@ -27,7 +26,7 @@ const draw = registerShapeUtils<DrawShape>({
|
||||||
parentId: 'page0',
|
parentId: 'page0',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
points: [[0, 0]],
|
points: [],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
isAspectRatioLocked: false,
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
|
@ -50,7 +49,12 @@ const draw = registerShapeUtils<DrawShape>({
|
||||||
pathCache.set(
|
pathCache.set(
|
||||||
points,
|
points,
|
||||||
getSvgPathFromStroke(
|
getSvgPathFromStroke(
|
||||||
getStroke(points, { size: +style.strokeWidth * 2, thinning: 0.9 })
|
getStroke(points, {
|
||||||
|
size: +style.strokeWidth * 2,
|
||||||
|
thinning: 0.9,
|
||||||
|
end: { taper: 100 },
|
||||||
|
start: { taper: 100 },
|
||||||
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue