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

Fix to use offsetTop of absolute positioned container element #330

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mindfull
Copy link

@mindfull mindfull commented May 25, 2018

Hello,

I had been suffered from scroll offset error, and I've finally found scrollOffset function in modules/mixins/utils.js is not working properly when container is absolute positioned element.

I'm actually using react-custom-scrollbars to customize scrollbars, and it makes container element as an absolute positioned element. Because the computed position property of the container element is not relative but absolute, scroller changes scrollTop to wrong position.

I tried to change 26th line of modules/mixins/utils.js from

      t.getBoundingClientRect().top + (window.scrollY || window.pageYOffset) : getComputedStyle(c).position === "relative" ? t.offsetTop : (t.getBoundingClientRect().top + c.scrollTop)

to

      t.getBoundingClientRect().top + (window.scrollY || window.pageYOffset) : getComputedStyle(c).position !== "static" ? t.offsetTop : (t.getBoundingClientRect().top + c.scrollTop)

and all of my problem is gone.

** In addition, I also tested this changes for fixed positioned container element, it worked properly.

@mindfull mindfull changed the title Fix to use offsetTop of absolute positioned element Fix to use offsetTop of absolute positioned container element May 25, 2018
@fabioberger
Copy link

I had the same issue, but my container div was absolutely positioned, so I had to change this to "absolute". Are these just missing edge-cases @fisshy, or are we doing something wrong?

fabioberger added a commit to 0xProject/0x-monorepo that referenced this pull request Aug 3, 2018
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

Successfully merging this pull request may close these issues.

2 participants