Bug Tracker

Modify

Ticket #6483 (closed bug: worksforme)

Opened 22 months ago

Last modified 12 months ago

[v1.4.2]jQuery.fn.offset(newOffset) issue

Reported by: david.yu Owned by: david.yu
Priority: undecided Milestone: 1.4.3
Component: dimensions Version: 1.4.2
Keywords: offset Cc:
Blocking: Blocked by:

Description

When current element has an "absolute" position, and offsetParent of this element is BODY, jQuery.curCSS( elem, "top", true ) maybe get "auto" in safari4/IE8, and curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) | | 0, will return 0, then props will lost really top and left pixel value of current element.

var props = { top: (options.top - curOffset.top) + curTop, left: (options.left - curOffset.left) + curLeft}

Change History

comment:1 Changed 22 months ago by david.yu

var props = {

top: (options.top - curOffset.top) + curTop,

left: (options.left - curOffset.left) + curLeft

};

add below line to fix this issue.

if (jQuery.nodeName(curElem.offsetParent()[0], 'body') && curElem.css('position') === 'absolute') {

props = {top: options.top, left: options.left};

}

comment:2 Changed 20 months ago by dmethvin

  • Component changed from unfiled to dimensions

comment:3 Changed 16 months ago by rwaldron

  • Owner set to david.yu
  • Priority set to undecided
  • Status changed from new to pending

Please provide a reduced jsFiddle test case, thanks!

Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.

comment:4 Changed 16 months ago by anonymous

using jquery-1.4.3.js in google chrome6:  http://jsfiddle.net/kCC9A/1/ setOffset method in version 1.4.3 is right now.

using jquery-1.4.2.js in google chrome6(FF is right):  http://jsfiddle.net/kCC9A/2/ setOffset method does not run as expected.

comment:5 Changed 15 months ago by addyosmani

  • Status changed from pending to closed
  • Resolution set to worksforme

As can be verified by looking at the test case for jQuery 1.4.3 provided above and the following test case  Live Test Case for jQury 1.4.4, the offset behavior originally described seems to be working fine now.

If there are any additional comments or test cases you would like to submit for us to investigate, please feel free to re-submit them and we'll take a look.

Thanks!

Last edited 15 months ago by addyosmani (previous) (diff)

comment:6 Changed 12 months ago by anonymous

The above fix works in 1.4.2 but not in the latest releases

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.