Skip to content

Commit dc10bf4

Browse files
committed
docs: improve touch device UX
1 parent 21c7ccb commit dc10bf4

File tree

6 files changed

+29
-4
lines changed

6 files changed

+29
-4
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,18 @@ The overlay can be customized with style and className props:
11081108
/>
11091109
```
11101110

1111+
## Troubleshooting
1112+
1113+
### Touch devices
1114+
1115+
On touch devices, you might need to disable the default touch behavior to prevent the page from scrolling on drag, by
1116+
setting the `touch-action: none` in CSS, on the draggable elements or its parent.
1117+
1118+
```tsx
1119+
// Example using Tailwind CSS
1120+
<DragOverlayProvider className="touch-none">{/* Your draggable and droppable components */}</DragOverlayProvider>
1121+
```
1122+
11111123
## Author
11121124

11131125
Javier Aguilar

llms.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,3 +845,16 @@ CODE:
845845
```
846846

847847
----------------------------------------
848+
849+
TITLE: Touch devices
850+
DESCRIPTION: On touch devices, you might need to disable the default touch behavior to prevent the page from scrolling on drag, by setting the `touch-action: none` in CSS, on the draggable elements or its parent.
851+
SOURCE: https://github.com/pizzajsdev/dragswag/blob/main/README.md#touch-devices
852+
853+
LANGUAGE: tsx
854+
CODE:
855+
```
856+
<div className="touch-none">
857+
<DraggableSquare />
858+
</div>
859+
```
860+

packages/docs/app/examples/draggable-grid-cells/draggable-grid-cells.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const DraggableSquare = ({ color, className }: { color: string; className?: stri
1414
const opacity = isDragging ? 0.5 : 1
1515

1616
return draggable(
17-
<div className={cn('square', className)} style={{ backgroundColor: color, opacity }}>
17+
<div className={cn('square touch-none', className)} style={{ backgroundColor: color, opacity }}>
1818
{isDragging ? 'Dragging' : 'Drag me'}
1919
</div>,
2020
)

packages/docs/app/examples/draggable-list/draggable-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function Item({ text, index, moveItem }: ItemProps) {
7575

7676
return droppable(
7777
draggable(
78-
<div className={cn('item-wrapper', isDragging && 'dragging')}>
78+
<div className={cn('item-wrapper touch-none', isDragging && 'dragging')}>
7979
<div
8080
className={cn(
8181
'item-placeholder',

packages/docs/app/examples/kanban-board/dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const Dashboard = () => {
158158
const { tasks } = useTasks()
159159

160160
return (
161-
<Styled.DashboardColumns>
161+
<Styled.DashboardColumns className="touch-none flex-col sm:flex-row">
162162
{columns.map((column) => (
163163
<Column
164164
key={column.status}

packages/docs/app/routes/examples/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Outlet } from 'react-router'
44

55
export default function Layout() {
66
return (
7-
<div className="p-16">
7+
<div className="p-4 sm:p-16">
88
<header className="flex flex-col items-center gap-4 text-center">
99
<Logo withHeading />
1010
<Heading tagName="h2">Examples</Heading>

0 commit comments

Comments
 (0)