ThemeForest

Chrome - offset().top acting like scrollTop()

636 posts
  • Has been a member for 3-4 years
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Envato Staff
  • Support Staff
  • Beta Tester
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • United States
  • Referred between 500 and 999 users
cudazi says

I have an odd issue I’ve tracked down to the way chrome 12.0.7 is returning the offset().top value.

I’ve simplified the code down to this sample for testing: (Any time a link is clicked, it should just log the position of an item with the ID of portfolio no matter where you are on the page.)

$('a').click(function() {
    console.log( $('#portfolio').offset().top );    
});

Firefox and Safari work fine, but with Chrome (12.0.7 mac) the value changes depending on where you’re scrolled to along the page like it’s returning scrollTop().

Thanks for any ideas. :)

1 year ago
cudazi is an Envato staff member
636 posts
  • Has been a member for 3-4 years
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Envato Staff
  • Support Staff
  • Beta Tester
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • United States
  • Referred between 500 and 999 users
cudazi says

...like it’s returning scrollTop().

Like it’s returning $(window).scrollTop() I meant to say.

1 year ago
cudazi is an Envato staff member
1210 posts
  • Has been a member for 2-3 years
  • Community Superstar
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Bought between 50 and 99 items
  • Austria
  • Referred between 200 and 499 users
revaxarts says

Is the parent element set to position:relative ?

1 year ago
636 posts
  • Has been a member for 3-4 years
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Envato Staff
  • Support Staff
  • Beta Tester
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • United States
  • Referred between 500 and 999 users
cudazi says

No luck on my local example but I think you may be on the right track.

1 year ago
cudazi is an Envato staff member
636 posts
  • Has been a member for 3-4 years
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Envato Staff
  • Support Staff
  • Beta Tester
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • United States
  • Referred between 500 and 999 users
cudazi says

It seems the target item needs to be explicitly set position: relative for the latest version of Chrome.

1 year ago
cudazi is an Envato staff member
by
by
by
by
by