clauderic / clauderic/react-sortable-hoc

Cannot auto scroll in mobile devices, when useWindowAsScrollContainer is true

Open
#758 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
10.9k
Forks
959
PR merge metrics
No merged PRs in 30d

Description

`document.scrollingElement` is BODY in mobile devices, and HTML in PC.
When set `useWindowAsScrollContainer` to be true, `AutoScroller` will use document.scrollingElement(here is BODY element), the code can be found in https://github.com/clauderic/react-sortable-hoc/blob/master/src/SortableContainer/index.js#L93

However, in this case, document.body.clientHeight is always equal with document.body.scrollHeight.So, `isBottom` here will always be true, and cannot auto scroll.
https://github.com/clauderic/react-sortable-hoc/blob/master/src/AutoScroller/index.js#L40

I tried to replace `const isBottom = scrollHeight - scrollTop - clientHeight === 0;` with `const isBottom = scrollHeight - scrollTop - (this.container === document.scrollingElement ? window.innerHeight : clientHeight) === 0;`, and it works.

`this.container === document.scrollingElement` will be `true`, when we set `useWindowAsScrollContainer` to be `true`

```jsx
false}
pressDelay={100}
helperContainer={() => this.formRef.current}
useWindowAsScrollContainer
lockToContainerEdges
/>
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.