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

Why use target as scroll parent if position: fixed? #214

Open
matthewgertner opened this issue Sep 20, 2016 · 4 comments
Open

Why use target as scroll parent if position: fixed? #214

matthewgertner opened this issue Sep 20, 2016 · 4 comments

Comments

@matthewgertner
Copy link

I noticed https://github.com/HubSpot/tether/blob/master/src/js/utils.js#L41 and I'm really just curious to know why the target is considered the scroll parent if it is position: fixed.

@DiscoNova
Copy link

I'm not exactly certain if I understood the question correctly, but a parent element with position: fixed is fixed to the window, and regardless of what it is contained in (some further containers, body-element, whatever) in theory do not contribute to the element's scroll-position ... of course, I do see a problem with this when the target element is removed from within the parent and placed under body - where all sorts of things do have an effect on it...

@TrevorBurnham
Copy link
Contributor

TrevorBurnham commented Sep 20, 2016

I believe the reason is that if the target is position: fixed, then scroll events fired from other elements are irrelevant—they won't affect the tether's position. So this logic avoids attaching unnecessary scroll listeners to the target's ancestors.

On the other hand, this results in an unnecessary scroll listener to the target itself—scrolling within the target shouldn't affect the tether's position either (right?).

So perhaps getScrollParents should actually return [] in the position: fixed case. Does that make sense?

@matthewgertner
Copy link
Author

Well the problem I was encountering is that the tether gets tether-out-of-bounds classes if it is larger than the target. This is presumably not the desired behavior. What would be the behavior if an empty array is returned by getScrollParents and the tether is configured to be constrained to its scroll parent? If it simply ignores the constraint, I would say that's probably fine.

@DiscoNova
Copy link

Could you provide a simplified jsfiddle (or something) example of what you're trying to do? Just because I'm having hard time visualizing the issue.

Do you have constraint assigned to "scrollParent"? Because it sounds like you have, and the "out-of-bounds" sounds exactly correct behaviour if the tethered element is larger than the target (since it will never fit within the bounds). If you do ... why? And if you don't ... well ... then we might actually have a problem ;)

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