Skip to content

Commit

Permalink
Fix: inability to drag gallery on touch devices (#14)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andrewrubin authored Nov 14, 2023
1 parent 1cc95ac commit a12e2b6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
15 changes: 14 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
<title>@wethegit/react-gallery</title>
<style>
body {
overscroll-behavior: none;
}

.gallery {
overflow: hidden;
}

img {
max-width: 100%;
}
</style>
</head>
<body>
<div id="root"></div>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wethegit/react-gallery",
"version": "3.0.1",
"version": "3.0.2",
"description": "A customizable, accessible gallery component for React projects.",
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/gallery-context.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const Gallery = ({
return (
<GalleryContext.Provider value={value}>
<div
className={classnames(["gallery", className])}
className={classnames(["gallery", draggable && "gallery--draggable", className])}
style={{ "--touch-offset": touchState.xOffset }}
>
{children}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/components/gallery.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
width: 100%;
}

.gallery--draggable {
touch-action: pan-y;
}

.gallery__main {
display: grid;
grid-template-areas: "item";
Expand Down

0 comments on commit a12e2b6

Please sign in to comment.