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

Removing touch scroll disabling styles if dragListener is false #1363

Merged
merged 4 commits into from Nov 23, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ Framer Motion adheres to [Semantic Versioning](http://semver.org/).

- Ensuring forced renders are batched so sibling `AnimatePresence` renders are triggered together. [Issue](https://github.com/framer/motion/issues/1358)
- Viewport enter/leave event handlers are passed `IntersectionObserverEntry` or `null` if `IntersectionObserver` is not supported on the device. [Issue](https://github.com/framer/motion/issues/1364)
- No longer applying touch scroll-disabling styles if `dragListener` is set to `false`. [Issue](https://github.com/framer/motion/issues/1341)

## [5.3.1] 2021-11-19

Expand Down
14 changes: 14 additions & 0 deletions src/motion/__tests__/ssr.test.tsx
Expand Up @@ -137,6 +137,20 @@ function runTests(render: (components: any) => string) {
)
})

test("Reorder: Doesn't render touch-scroll disabling styles if dragListener === false", () => {
function Component() {
const [state, setState] = React.useState([0])
return (
<Reorder.Group onReorder={setState} values={state}>
<Reorder.Item value="a" dragListener={false} />
</Reorder.Group>
)
}
const div = render(<Component />)

expect(div).toBe(`<ul><li style="z-index:0;transform:none"></li></ul>`)
})

test("Reorder: Renders provided element", () => {
function Component() {
const [state, setState] = React.useState([0])
Expand Down
8 changes: 5 additions & 3 deletions src/render/html/use-props.ts
Expand Up @@ -70,13 +70,15 @@ export function useHTMLProps(
const htmlProps: any = {}
const style = useStyle(props, visualState, isStatic)

if (Boolean(props.drag)) {
if (Boolean(props.drag) && props.dragListener !== false) {
// Disable the ghost element when a user drags
htmlProps.draggable = false

// Disable text selection
style.userSelect = style.WebkitUserSelect = style.WebkitTouchCallout =
"none"
style.userSelect =
style.WebkitUserSelect =
style.WebkitTouchCallout =
"none"

// Disable scrolling on the draggable direction
style.touchAction =
Expand Down