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

Scrolling When Hitting End of Scrollview #78

Open
harryrein3 opened this issue Feb 17, 2023 · 3 comments
Open

Scrolling When Hitting End of Scrollview #78

harryrein3 opened this issue Feb 17, 2023 · 3 comments

Comments

@harryrein3
Copy link

harryrein3 commented Feb 17, 2023

Hello, I have a list of 25 items that are each 25% of the screen height. When I try to move the first item to the 10th spot, the containing scrollview does not scroll when you hit the bottom of the parent view.

Have you handled this case in your solution?

I built a custom "auto-scroller", but the issue is when you scroll the scrollview behind the scenes, the cell being dragged also scrolls since the positioning seems relative to the scrollview.

  const [startDragPosition, setStartDragPosition] = useState(scrollViewRefScrollY);
  const [isAutoDragging, setIsAutoDragging] = useState(false);
  const [dragDistance, setDragDistance] = useState(scrollViewRefScrollY);
  const handleAutoScroll = data => {
   if (!enableAutoScroll || isAutoDragging) return;
   const screenHeightRatio = (100 * data.moveY) / DEVICE.height;
   const isNearTop = screenHeightRatio < 20;
   const isNearBottom = screenHeightRatio > 80;

    if (isNearTop) {
      const totalDragDistance = dragDistance - 200;
      setIsAutoDragging(true);
      scrollViewRef?.current?.scrollTo({ y: startDragPosition + totalDragDistance, animated: true });
      setTimeout(() => setIsAutoDragging(false), 200);
      setDragDistance(totalDragDistance);
    }
    if (isNearBottom) {
      const totalDragDistance = dragDistance + 200;
      setIsAutoDragging(true);
      scrollViewRef?.current?.scrollTo({ y: startDragPosition + totalDragDistance, animated: true });
      setTimeout(() => setIsAutoDragging(false), 200);
      setDragDistance(totalDragDistance);
    }
  };

Can you assist?

@arunvignesh-foodhub
Copy link

Any update on the above one? If so kindly assist

@harryrein3
Copy link
Author

Nothing yet, waiting on a solution as well

@MianIbrarHussain
Copy link

Have anybody found the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants