Side navigation
#5517 closed bug (invalid)
Opened November 16, 2009 07:10AM UTC
Closed December 04, 2010 08:05AM UTC
Last modified July 24, 2013 11:10AM UTC
.offset().top gives incorrect values
Reported by: | rene___ | Owned by: | rene___ |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4 |
Component: | offset | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I use the code below to get the optimum scrolltop position for a comment, so the comment will be scrolled to the center of the window (div).
function getDivScrollTop(Div) {
var Comments = $('#comments');
var Comment = $(Div);
var Top = Comment.offset().top;
var Sibling = Comment.next();
var ViewportHeight = parseInt(Comments.css('height'));
var NewTop = Top - ((ViewportHeight - (Sibling.offset().top-Top)) / 2);
if (NewTop > Top) {
NewTop = Top - (ViewportHeight / 4);
}
return NewTop;
}
But since I changed it from:
Comments[0].offsetTop too Comments.offset().top,
it alternates in right values and then completely wronge values.
I attached a screencapture from IE7's debuggers watches window.
I also tested it with the latest version of Chrome, and the problem is the same.
Attachments (1)
Change History (4)
Changed November 16, 2009 04:10PM UTC by comment:1
Changed November 19, 2010 10:01PM UTC by comment:2
owner: | brandon → rene___ |
---|---|
status: | new → pending |
Please provide a reduced test case demonstrating this issue on jsFiddle.
Changed December 04, 2010 08:05AM UTC by comment:3
resolution: | → invalid |
---|---|
status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
Changed July 24, 2013 11:10AM UTC by comment:4
Thanks for your getOffset function above. This worked perfectly for us!
Another issue which I think is related to offset().top under IE 7&8.
For example - I have an element in an IFrame which I want to position absolutely. When scrolling the whole frame offset().top still returns one and the same position. I've fixed it with adding the scrollTop distance.
Under FF and Chrome there is no such problem.