Ticket #6809 (closed enhancement: fixed)
Add jQuery.support.fixedPosition
| Reported by: | scott.gonzalez | Owned by: | rwaldron |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.7 |
| Component: | support | Version: | 1.4.2 |
| Keywords: | 1.7-discuss | Cc: | |
| Blocking: | Blocked by: |
Description
jQuery already detects support for fixed positioning in the offset code. jQuery.offset.supportsFixedPosition should be moved to jQuery.support.fixedPosition and calculated immediately.
Change History
comment:4 Changed 2 years ago by borisov.gleb@…
I think that other properties should live in jQuery.offset, just because they're internal and used only in offset.js. I have just forked jquery on github and pushed changed to my master-branch. Also created pull-request for this change.
comment:5 Changed 2 years ago by rwaldron
I'm not sure about this particular patch (no offense) but I definitely think this should be reviewed further.
comment:6 Changed 2 years ago by paul.irish
Here is the relevant jQuery.offset.supportsFixedPosition code fwiw: https://github.com/jquery/jquery/blob/eed380/src/offset.js#L125-143
It should certainly execute lazily, but augmenting jQuery.support proper makes sense to me.
comment:9 Changed 2 years ago by john
- Keywords 1.7-discuss added
Nominating ticket for 1.7 discussion.
comment:10 Changed 2 years ago by rwaldron
+1,
comment:11 Changed 2 years ago by jaubourg
+1, There is no reason why offset should keep a private repository of support properties... ajax does its own support tests yet publishes the result on the main support object.
comment:12 Changed 2 years ago by ajpiano
+1,
comment:13 Changed 2 years ago by timmywil
+1, Makes sense.
comment:14 Changed 2 years ago by paul.irish
+1,
though.. iOS false positives on nearly all written fixed pos tests (incl this one); https://github.com/Modernizr/Modernizr/issues/167
Might be unsolvable and leave it up to docs to explain
comment:15 Changed 2 years ago by dmethvin
+1, If some code can benefit from precomputing it, rather than on-demand, fine.
comment:16 Changed 2 years ago by john
+1, Seems easy enough.
comment:17 Changed 2 years ago by scott.gonzalez
+1
comment:18 Changed 2 years ago by jzaefferer
+1
comment:19 Changed 23 months ago by dmethvin
- Priority changed from low to blocker
- Milestone changed from 1.next to 1.7
comment:20 Changed 23 months ago by iMarc
This false-positive iOS < 5 bug was driving me crazy. The only difference between normal browsers that do support position: fixed and iOS < 5 that I found was that offsetParent is null inside a relative element (code below). Not sure if that is at all related, but I was simply obsessed with locating any difference I could find that might be related to the iOS rendering issue of position fixed..
var test = document.createElement('div'),
control = test.cloneNode(false),
wrap = test.cloneNode(false),
fake = false,
root = document.body || (function () {
fake = true;
return document.documentElement.appendChild(document.createElement('body'));
}());
root.appendChild(wrap);
wrap.appendChild(test);
wrap.appendChild(control);
wrap.style.cssText = 'position:relative;';
test.style.cssText = 'position:fixed;';
control.style.cssText = 'position:absolute;';
alert(!!control.offsetParent); // alerts true in all browsers, even iOS
alert(!!test.offsetParent); // alerts false in iOS
if (fake) {
document.documentElement.removeChild(root);
}
comment:22 Changed 22 months ago by rwaldron
The problem I'm initially running into is that support is generally run before before the real body actually exists... I think I can work around that, draft implementation to follow.
comment:23 Changed 22 months ago by rwaldron
Working draft: https://github.com/rwldrn/jquery/tree/6809
Currently the only failing tests are:
offset: body (2, 0, 2)
comment:24 Changed 22 months ago by john
Isn't this the case where you can do:
body = document.createElement("body");
to get the body element, even if it doesn't exist yet?
comment:25 Changed 22 months ago by rwaldron
Yes - I'm using document.body if it happens to exist early enough or the fake body that the support module has already created as a backup
@ https://github.com/rwldrn/jquery/commit/1f1990431a9abb8e964825e5bf7bd7c1eb28fa1b
comment:26 Changed 21 months ago by anonymous
This works: http://mnobeta.no/2011/09/test-position-fixed-for-iphone/ On iphone. Android needs to be taken care of.
comment:27 Changed 20 months ago by Rick Waldron
- Status changed from assigned to closed
- Resolution set to fixed
Landing pull request 477. 1.7 jQuery.offset.supportsFixedPosition. Fixes #6809.
More Details:
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Would it make sense to move the others such as doesNotAddBorder as well?