Skip to content

Commit

Permalink
Update pan drag cursor (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghsteff authored Jul 11, 2024
1 parent 64e2683 commit dba72a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
13 changes: 9 additions & 4 deletions src/Canvas.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@
pointer-events: none;
}

.hideScrollbars {
.draggable {
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* Internet Explorer 10+ */
}
cursor: grab;

&::-webkit-scrollbar {
display: none; /* WebKit */
}

.hideScrollbars::-webkit-scrollbar {
display: none; /* WebKit */
&:active {
cursor: grabbing;
}
}
24 changes: 12 additions & 12 deletions src/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const InternalCanvas: FC<CanvasProps & { ref?: Ref<CanvasRef> }> = forwardRef(({
{
onDrag: ({ movement: [mx, my] }) => {
// Update container scroll position during drag
if (containerRef.current) {
if (containerRef.current && !canvasDragNode) {
containerRef.current.scrollLeft = panStartScrollPosition.current.x - mx;
containerRef.current.scrollTop = panStartScrollPosition.current.y - my;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ const InternalCanvas: FC<CanvasProps & { ref?: Ref<CanvasRef> }> = forwardRef(({
style={{ height, width }}
className={classNames(css.container, className, {
[css.pannable]: pannable,
[css.hideScrollbars]: panType === 'drag'
[css.draggable]: panType === 'drag'
})}
ref={(el) => {
// Really not a fan of this API change...
Expand Down Expand Up @@ -327,17 +327,17 @@ const InternalCanvas: FC<CanvasProps & { ref?: Ref<CanvasRef> }> = forwardRef(({
scale: zoom,
transition: animated
? {
velocity: 100,
translateX: { duration: mount.current ? 0.3 : 0 },
translateY: { duration: mount.current ? 0.3 : 0 },
opacity: { duration: 0.8 },
when: 'beforeChildren'
}
velocity: 100,
translateX: { duration: mount.current ? 0.3 : 0 },
translateY: { duration: mount.current ? 0.3 : 0 },
opacity: { duration: 0.8 },
when: 'beforeChildren'
}
: {
type: false,
duration: 0,
when: 'beforeChildren'
}
type: false,
duration: 0,
when: 'beforeChildren'
}
}}
>
{layout?.children?.map(({ children, ...n }) => {
Expand Down

0 comments on commit dba72a8

Please sign in to comment.