Skip to content

Commit a12e2b6

Browse files
authored
Fix: inability to drag gallery on touch devices (#14)
* fix(docs): add GalleryPaginationItem to table of contents [skip-ci] * fix(Gallery): add touch-action CSS when draggable * style(demo): manage overflow * 3.0.2
1 parent 1cc95ac commit a12e2b6

5 files changed

Lines changed: 22 additions & 5 deletions

File tree

index.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite + React</title>
7+
<title>@wethegit/react-gallery</title>
8+
<style>
9+
body {
10+
overscroll-behavior: none;
11+
}
12+
13+
.gallery {
14+
overflow: hidden;
15+
}
16+
17+
img {
18+
max-width: 100%;
19+
}
20+
</style>
821
</head>
922
<body>
1023
<div id="root"></div>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wethegit/react-gallery",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "A customizable, accessible gallery component for React projects.",
55
"files": [
66
"dist"

src/lib/components/gallery-context.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const Gallery = ({
118118
return (
119119
<GalleryContext.Provider value={value}>
120120
<div
121-
className={classnames(["gallery", className])}
121+
className={classnames(["gallery", draggable && "gallery--draggable", className])}
122122
style={{ "--touch-offset": touchState.xOffset }}
123123
>
124124
{children}

src/lib/components/gallery.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
width: 100%;
2323
}
2424

25+
.gallery--draggable {
26+
touch-action: pan-y;
27+
}
28+
2529
.gallery__main {
2630
display: grid;
2731
grid-template-areas: "item";

0 commit comments

Comments
 (0)