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

Inside iframe this component does not render a custom scrollbar but a native scrollbar #34

Open
saxenarajat opened this issue Aug 25, 2022 · 2 comments

Comments

@saxenarajat
Copy link

saxenarajat commented Aug 25, 2022

As soon as, I switch the tabs and come back to the original tab, the native scrollbar is replaced with the custom scrollbar. Can anybody tell me what this behavior is?

Thanks for this library.

@alexaaaant
Copy link

I had the same issue. My problem was that iframe was rendering content with style display:none, so scroll was not able to get the actual container height

@d2r-app
Copy link

d2r-app commented Mar 31, 2023

Thanks for the tip @alexaaaant. The following seems to work for loading my component within an iframe:

  const [windowWidth, setWindowWidth] = useState(window.innerWidth);
  const [windowHeight, setWindowHeight] = useState(window.innerHeight);

  const onResize = useCallback(() => {
    setWindowWidth(window.innerWidth);
    setWindowHeight(window.innerHeight);
  }, []);

  useEffect(() => {
    window.addEventListener('resize', onResize);
    return () => { window.removeEventListener('resize', onResize) };
  }, [onResize]);
{!!windowWidth && !!windowHeight && <Scrollbars>...</Scrollbars>}

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