Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pan drag cursor #260

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading