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

Reject parent with overflow set to visible #41

Merged
merged 1 commit into from
Oct 26, 2016

Conversation

jeremenichelli
Copy link
Collaborator

@jeremenichelli jeremenichelli commented Sep 25, 2016

@iamdustan this fixes issue #36 review when you have time to see if I am missing something.

Description: in cases where the overflow style property is set to visible and children are absolute positioned the script needs to scroll the body instead of the scrollable parent.

@KitaitiMakoto with this fix, the example you provided in the first comment of the issue is mitigated; after merged test it on your project locally to see if it works there too.

el.clientWidth < el.scrollWidth;
hasVisibleOverflow =
w.getComputedStyle(el, null).overflow === 'visible';
} while (!isBody && !(hasScrollableSpace && !hasVisibleOverflow));
Copy link
Collaborator Author

@jeremenichelli jeremenichelli Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bare with me and this not so clear statement. Script will keep looking for a parent to scroll unless the element is the body element or has space to scroll but overflow is not set to visible. I hope that simplifies the reading.

|| el.clientWidth < el.scrollWidth));

// set condition variables
isBody = el === d.body;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we bail out early if any of these conditions are true? The reason is because the clientHeight/scrollHeight properties force layout.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can bail if the closest parent of the element is the body. That said I don't know in how many cases this will actually happen so I'm not seeing a real benefit but if you think is worth it I'll add at top @iamdustan

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, that’s okays.

@iamdustan
Copy link
Owner

This looks legit to me, @jeremenichelli. Do we want to land this along with any other open PRs and cut another release?

@jeremenichelli
Copy link
Collaborator Author

jeremenichelli commented Oct 10, 2016

@iamdustan this is en edge case so I prefer to wait a few days and see what happens with #42 so we can ship both.

Plus, if I have time, I might do the periodically revision I do and see if there's room for improvements in code or build steps.

@jeremenichelli jeremenichelli merged commit 42f593e into master Oct 26, 2016
@jeremenichelli jeremenichelli deleted the fix-overflow-visible-parent branch December 7, 2016 21:56
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.

None yet

2 participants