jQuery position() / scrollTop() inaccuracy
I have a bunch of div
s in a larger div that scrolls.
I want to scroll programmatically to a 'selected' inner div
. So I get position().top
of the inner div
and set this value using scrollTop()
on the outer div
.
Great, it works, almost.
The scroll distance is approximately 0.4%
out. The further down the list of div
s 开发者_开发百科I attempt to scroll to, the further out the calculation is. I have mitigated the issue by:
outerDiv.scrollTop(innerDiv.position().top * 1.004);
Is this just a rounding issue internal to jQuery? Has anyone else found this?
(And yes, the outer div is set toposition: relative
)
精彩评论