Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Commit b0dac0c

Browse files
authored
Merge pull request #41 from PsycleResearch/fix/path-drawing-after-move
fix: Path drawing after move
2 parents d48d2a6 + 7486d73 commit b0dac0c

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@psycle/repsycle",
3-
"version": "0.0.30",
3+
"version": "0.0.31",
44
"description": "Psycle Research front-end toolkit",
55
"author": "Psycle Research",
66
"keywords": [

src/draw-zone/components.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function DrawZoneInner({
238238
position: 'relative',
239239
pointerEvents: 'auto',
240240
touchAction: 'none',
241-
userSelect: 'none'
241+
userSelect: 'none',
242242
}}
243243
ref={containerRef}
244244
>
@@ -407,6 +407,20 @@ function SvgZone({
407407
[pointOnPointerDown],
408408
)
409409

410+
useEffect(() => {
411+
const { current } = ref
412+
413+
if (!current) return
414+
415+
const svg = SVG(current) as Svg
416+
417+
if (move) {
418+
svg.css({ cursor: 'grab' })
419+
} else {
420+
svg.css({ cursor: 'default' })
421+
}
422+
}, [move])
423+
410424
useEffect(() => {
411425
const { current } = ref
412426

@@ -446,6 +460,8 @@ function SvgZone({
446460

447461
dragging.current = true
448462

463+
svg.css({ cursor: 'grabbing' })
464+
449465
return
450466
}
451467

@@ -754,6 +770,7 @@ function SvgZone({
754770
svg.css({ cursor: 'grab' })
755771

756772
dragging.current = false
773+
startPosition.current = undefined
757774

758775
return
759776
}
@@ -805,11 +822,13 @@ function SvgZone({
805822

806823
if (drawOnPointerDown && lastRect && lastRect.rect) {
807824
currentPosition.x = Math.min(
808-
startPosition.current.x + lastRect.rect.width * scale,
825+
startPosition.current.x +
826+
lastRect.rect.width * scale,
809827
svgRect.width,
810828
)
811829
currentPosition.y = Math.min(
812-
startPosition.current.y + lastRect.rect.height * scale,
830+
startPosition.current.y +
831+
lastRect.rect.height * scale,
813832
svgRect.height,
814833
)
815834
} else {

0 commit comments

Comments
 (0)