-
Notifications
You must be signed in to change notification settings - Fork 512
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
Element.prototype.getPosition does not properly handle elements with fixed position parents #2766
Comments
@Continuities thanks for reporting this. If you could provide a jsFiddle or example that reproduces the problem would be great. Cheers |
https://jsfiddle.net/Continuities/bo1zm146/3/
|
afaik this is expected behaviour. getPosition is calculated re: relative positioned parent. CSS behaves smilarly: offset is specified re: relative positioned parent. |
It's expected that getPosition should behave differently between iOS and desktop Chrome? |
top div is rarely set position:fixed. This may be allowed however this may be causing the issue. I just tried to wrap entire html in another generic behaviour is similar to desk Chrome: the number is updated. just remember that position get / set works relative to nearest non-fixed parent. This is aligned with CSS. |
Not the behaviour I'm seeing. Wrapping the entire thing in an unstyled div does nothing to change the inconsistency between desktop and iOS. I know exactly where the bug is, and reported it in the original issue description. |
how do you spoof iOS? what if you getOffsetParent and pass the parent to getPosition? does it work as you need it? if position is calculated relative to any parent regardless of their fixed / relative attribute, this would lead to different behaviour from CSS and from how it works now. |
Chrome dev tools with an iOS user-agent. I don't really care which behaviour you choose (either document-, or viewport-relative), I just want it to be consistent between platforms. It should not be necessary to implement workarounds (like getOffsetParent) to achieve consistency. |
I use toggle device toolbar. Is this the same thing? actually, even without adding generic div, behaviour is similar. there may be differences in Chrome versions. Do you use Linux too? also (just checking) did you disable cache in dev-tools? |
Are you reloading between switching devices? The user-agent is only actually updated if you refresh. It's not a Chrome issue, it's caused by the two different code-paths in The first block (inside the I can fix the issue myself, if necessary. I just don't want to bother cloning the project and making a pull request. |
I tried to reload. js fiddle code (not your snippet, jsfiddle editor js file) throws an error. Scrolling behaviour after this error is very odd: the scroll hand moves in the opposite direction from cursor. I suppose it may be caused by jsfiddle's error. As a side note: I am not Mootools library dev - a user like yourself. I remembered I was surprised to find out how position fixed and relative are different. Thought I could help. To check your code, I need to load your example outside of jsFiddle. Let me do this in the next few days. If you change the library, please do not change desktop Chrome behaviour. |
That just sounds like it's switched to touch-based scrolling. There is a jsFiddle error thrown, but it doesn't appear to cause any problems.
See, that's the issue. I think iOS is behaving correctly in this instance, and not desktop Chrome. Behaviour could be consolidated to be "wrong" everywhere, but that doesn't feel like the right answer. I'll leave it up to the MooTools dev community. |
just noticed that https://jsfiddle.net/Continuities/bo1zm146/3/ does not use MooTools. Javascript is set to No-library (pure Js) is this intended? Are we testing MooTools then? |
It's an external dependency. None of the code would work without MooTools. |
While trying to write a spec to capture this behaviour, I discovered another interesting quirk: The bug disappears if the scrolling element is any element other than the window (ie, the fixed malarky is inside a div with |
do not iOS capture other event, not scroll? I modified your code to this iOS (drag?) behaves similar to desktop scroll |
That code still exhibits the inconsistent behaviour that I described. I don't think you're properly emulating iOS user-agents. |
I overlooked that sticky has position fixed and thought about absolute vs relative / not set attributes. I am not sure what getPosition should return for fixed elements and their children. I'd never tried it. Sorry about the confusion. I can't help. |
It's alright =) |
It looks like the intent is for
getPosition
to return a number relative to the viewport for fixed position elements. If an element is not fixed but nested inside a fixed element, however,getPosition
returns a number relative to the document. This is becauseisFixed
(on line 136 of Element.Dimensions.js) only checks the styling of the element itself.The problem is worse because the behaviour is inconsistent between desktop and iOS. iOS uses a different code-path in
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/32112238-element-prototype-getposition-does-not-properly-handle-elements-with-fixed-position-parents?utm_campaign=plugin&utm_content=tracker%2F22067&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F22067&utm_medium=issues&utm_source=github).getOffsets
that correctly returns a number relative to the viewport for elements inside fixed elements.The text was updated successfully, but these errors were encountered: