SMAKSS / react-scroll-direction

Detect scroll direction in react applications.
https://www.npmjs.com/package/@smakss/react-scroll-direction
MIT License
23 stars 4 forks source link

`ScrollDir` is always down #258

Closed astralarya closed 4 months ago

astralarya commented 5 months ago

Brief Description

The scroll direction hook always returns down, even when scrolling up.

Environment

Code Snippet

export default function Example() {
  const { scrollDir } = useDetectScroll();

  console.log(scrollDir);

  return "ababa";
}

Steps to Reproduce

Scroll up and down

Expected Behavior

Scrolling up returns up.

Actual Behavior

Events always return direction as down.

SMAKSS commented 4 months ago

Hello! Apologies for the delayed reply, and thank you 🙏 for bringing this to our attention. I'm on it and will investigate the issue immediately.

SMAKSS commented 4 months ago

Hi @astralarya,

Thanks for bringing this to my attention. Despite testing on Chrome, Firefox, and Safari with the same Node.js version, the issue couldn't be replicated on my end. To dive deeper and find a solution, could you please provide the following details?

  1. Browser and Version:
  2. Operating System:
  3. Bundler If any
  4. Console Errors/Warnings: If any.
  5. Specific Conditions: Under which the issue seems more pronounced, if applicable.
  6. Visuals: A video or screenshots capturing the issue, if possible.

Your further insights will be crucial for me to identify and address the problem effectively. I appreciate your cooperation and patience.

Thank you!

KubaZachacz commented 4 months ago

Hey @SMAKSS It's really looks like it might show 'Still' at start and only down 'Down' later Here's my: codesanbox I hope it will work enough to show the bug.

In general in my project and sandbox it's Node 20+ and Next.Js 14+ with appDir

SMAKSS commented 4 months ago

Thanks to @astralarya and @KubaZachacz for your support and contributions! I've deployed a fix. Please update to the latest version and check if it resolves the issue.

Looking forward to your feedback!