Bug Tracker

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#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:
Blocked by: Blocking:


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 (27)

comment:1 Changed 5 years ago by dmethvin

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

comment:2 Changed 5 years ago by rwaldron

  • Milestone changed from 1.4.3 to 1.5
  • Priority set to low

comment:3 Changed 5 years ago by snover

  • Status changed from new to open

comment:4 Changed 5 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 5 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 5 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:7 Changed 5 years ago by john

  • Milestone set to 1.next

Let's look at this for 1.7.

comment:9 Changed 5 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:10 Changed 5 years ago by rwaldron


comment:11 Changed 5 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 5 years ago by ajpiano


comment:13 Changed 5 years ago by timmywil

+1, Makes sense.

comment:14 Changed 5 years ago by paul.irish


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 5 years ago by dmethvin

+1, If some code can benefit from precomputing it, rather than on-demand, fine.

comment:16 Changed 4 years ago by john

+1, Seems easy enough.

comment:17 Changed 4 years ago by scott.gonzalez


comment:18 Changed 4 years ago by jzaefferer


comment:19 Changed 4 years ago by dmethvin

  • Milestone changed from 1.next to 1.7
  • Priority changed from low to blocker

comment:20 Changed 4 years 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'));


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) {

Version 0, edited 4 years ago by iMarc (next)

comment:21 Changed 4 years ago by john

  • Owner set to rwaldron
  • Status changed from open to assigned

comment:22 Changed 4 years 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 4 years 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 4 years 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 4 years 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

Last edited 4 years ago by rwaldron (previous) (diff)

comment:26 Changed 4 years 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 4 years ago by Rick Waldron

  • Resolution set to fixed
  • Status changed from assigned to closed

Landing pull request 477. 1.7 jQuery.offset.supportsFixedPosition. Fixes #6809.

More Details:

Note: See TracTickets for help on using tickets.