Skip to content

Commit dba72a8

Browse files
authored
Update pan drag cursor (#260)
1 parent 64e2683 commit dba72a8

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/Canvas.module.css

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@
2121
pointer-events: none;
2222
}
2323

24-
.hideScrollbars {
24+
.draggable {
2525
scrollbar-width: none; /* Firefox */
2626
-ms-overflow-style: none; /* Internet Explorer 10+ */
27-
}
27+
cursor: grab;
28+
29+
&::-webkit-scrollbar {
30+
display: none; /* WebKit */
31+
}
2832

29-
.hideScrollbars::-webkit-scrollbar {
30-
display: none; /* WebKit */
33+
&:active {
34+
cursor: grabbing;
35+
}
3136
}

src/Canvas.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const InternalCanvas: FC<CanvasProps & { ref?: Ref<CanvasRef> }> = forwardRef(({
225225
{
226226
onDrag: ({ movement: [mx, my] }) => {
227227
// Update container scroll position during drag
228-
if (containerRef.current) {
228+
if (containerRef.current && !canvasDragNode) {
229229
containerRef.current.scrollLeft = panStartScrollPosition.current.x - mx;
230230
containerRef.current.scrollTop = panStartScrollPosition.current.y - my;
231231
}
@@ -292,7 +292,7 @@ const InternalCanvas: FC<CanvasProps & { ref?: Ref<CanvasRef> }> = forwardRef(({
292292
style={{ height, width }}
293293
className={classNames(css.container, className, {
294294
[css.pannable]: pannable,
295-
[css.hideScrollbars]: panType === 'drag'
295+
[css.draggable]: panType === 'drag'
296296
})}
297297
ref={(el) => {
298298
// Really not a fan of this API change...
@@ -327,17 +327,17 @@ const InternalCanvas: FC<CanvasProps & { ref?: Ref<CanvasRef> }> = forwardRef(({
327327
scale: zoom,
328328
transition: animated
329329
? {
330-
velocity: 100,
331-
translateX: { duration: mount.current ? 0.3 : 0 },
332-
translateY: { duration: mount.current ? 0.3 : 0 },
333-
opacity: { duration: 0.8 },
334-
when: 'beforeChildren'
335-
}
330+
velocity: 100,
331+
translateX: { duration: mount.current ? 0.3 : 0 },
332+
translateY: { duration: mount.current ? 0.3 : 0 },
333+
opacity: { duration: 0.8 },
334+
when: 'beforeChildren'
335+
}
336336
: {
337-
type: false,
338-
duration: 0,
339-
when: 'beforeChildren'
340-
}
337+
type: false,
338+
duration: 0,
339+
when: 'beforeChildren'
340+
}
341341
}}
342342
>
343343
{layout?.children?.map(({ children, ...n }) => {

0 commit comments

Comments
 (0)