jQuery.scrollIntoView icon indicating copy to clipboard operation
jQuery.scrollIntoView copied to clipboard

Fix bug if the immediate offset parent is not also the immediate scrollable parent

Open theKidOfArcrania opened this issue 8 years ago • 0 comments

The original code uses Element.offsetTop and Element.offsetLeft to determine the offsets for the element within the Element.offsetParent. The code assumes that the offsetParent is the parent closest to the node that is scrollable. However, this is not always the case. The API says that the offsetParent is the parent closes the node that is positioned (i.e. has position: relative or position: absolute in the css), or it returns body if none of the parents are positioned. The code would run into a problem if one of the node's parents are positioned, but none of them are scrollable (it would use the offsets of the positioned parent and use those numbers to scroll the body). It would also run into a problem if one of the node's parents are scrollable, but aren't positioned (i.e. if you set a max-height in the css and also set overflow-y: scroll).

theKidOfArcrania avatar Nov 25 '16 18:11 theKidOfArcrania