-
Notifications
You must be signed in to change notification settings - Fork 11
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
How to use it in React? #14
Comments
havent tried it, but i bet you could just import this, get a ref to the node you want to get scrollend from, and then use that ref to setup the event listener? |
At least when I tried it in a playground and testing it in Safari 16.6, the polyfill didn't seem to kick in. When testing in browsers that support Am I missing something to make the polyfill work in React? Codeimport React from 'react';
import './App.css';
import { scrollend } from 'scrollyfills';
function App() {
const ref = React.useRef<HTMLDivElement>(null);
React.useEffect(() => {
const refCurrent = ref.current;
const listener = () => {
console.log('scrollend');
};
refCurrent?.addEventListener('scrollend', listener);
return () => {
refCurrent?.removeEventListener('scrollend', listener);
};
}, []);
return (
<>
<div
id="scroll-container"
ref={ref}
style={{ height: '50vh', overflow: 'auto' }}
>
<div
id="content"
style={{
height: '200vh',
backgroundColor: 'black',
}}
>
<p>Content</p>
</div>
</div>
</>
);
}
export default App; |
maybe there's a conflict with how React does events. perhaps they're consuming them to the root of the react app (which they've always done) but aren't forwarding the scrollend event? |
No description provided.
The text was updated successfully, but these errors were encountered: