Side navigation
#1036 closed bug (wontfix)
Opened March 09, 2007 09:25PM UTC
Closed March 31, 2008 01:34AM UTC
iutils getPositionLite fails with position:fixed
Reported by: | bluej | Owned by: | stefan |
---|---|---|---|
Priority: | major | Milestone: | 1.1.3 |
Component: | interface | Version: | 1.1.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
For elements that are or descent from elements that are position:fixed, getPositionLite returns the values they would have if they were position:absolute. I believe this is also true of getPosition itself.
Here is a fix that's working for me:
getPositionLite : function(el)
{
var x = 0, y = 0;
var fixed;
while(el) {
if (jQuery(el).css('position') == 'fixed') {
fixed = true;
}
x += el.offsetLeft || 0;
y += el.offsetTop || 0;
el = el.offsetParent;
}
if (fixed) {
if (window.pageXOffset != null) {
x += window.pageXOffset;
y += window.pageYOffset;
} else {
x += document.body.scrollLeft;
y += document.body.scrollTop;
}
}
return {x:x, y:y};
},
This patch solves the position:fixed problems with idrop.js.
Attachments (0)
Change History (1)
Changed March 31, 2008 01:34AM UTC by comment:1
description: | For elements that are or descent from elements that are position:fixed, getPositionLite returns the values they would have if they were position:absolute. I believe this is also true of getPosition itself.\ \ Here is a fix that's working for me:\ \ getPositionLite : function(el)\ {\ var x = 0, y = 0;\ var fixed;\ while(el) {\ if (jQuery(el).css('position') == 'fixed') {\ fixed = true;\ }\ x += el.offsetLeft || 0;\ y += el.offsetTop || 0;\ el = el.offsetParent;\ }\ if (fixed) {\ if (window.pageXOffset != null) {\ x += window.pageXOffset;\ y += window.pageYOffset;\ } else {\ x += document.body.scrollLeft;\ y += document.body.scrollTop;\ }\ }\ return {x:x, y:y};\ },\ \ This patch solves the position:fixed problems with idrop.js. → For elements that are or descent from elements that are position:fixed, getPositionLite returns the values they would have if they were position:absolute. I believe this is also true of getPosition itself. \ \ Here is a fix that's working for me: \ \ getPositionLite : function(el) \ { \ var x = 0, y = 0; \ var fixed; \ while(el) { \ if (jQuery(el).css('position') == 'fixed') { \ fixed = true; \ } \ x += el.offsetLeft || 0; \ y += el.offsetTop || 0; \ el = el.offsetParent; \ } \ if (fixed) { \ if (window.pageXOffset != null) { \ x += window.pageXOffset; \ y += window.pageYOffset; \ } else { \ x += document.body.scrollLeft; \ y += document.body.scrollTop; \ } \ } \ return {x:x, y:y}; \ }, \ \ This patch solves the position:fixed problems with idrop.js. |
---|---|
need: | → Review |
resolution: | → wontfix |
status: | new → closed |
Interface is no longer supported; consider switching to jQuery UI.