1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-28 07:39:57 +02:00

HTMLElement.offset* by getBoundingClientRect() (#21788)

* Replace element.offet* by getBoundingClientRect()

* Use variable to store BoundingClientRect

* Fix cc issue...
This commit is contained in:
Pierre Vanduynslager
2017-03-18 21:24:54 -04:00
committed by Mark Otto
parent f2f2e39a45
commit 275821bbb0
3 changed files with 12 additions and 11 deletions

View File

@@ -133,12 +133,15 @@ const ScrollSpy = (($) => {
target = $(targetSelector)[0]
}
if (target && (target.offsetWidth || target.offsetHeight)) {
// todo (fat): remove sketch reliance on jQuery position/offset
return [
$(target)[offsetMethod]().top + offsetBase,
targetSelector
]
if (target) {
const targetBCR = target.getBoundingClientRect()
if (targetBCR.width || targetBCR.height) {
// todo (fat): remove sketch reliance on jQuery position/offset
return [
$(target)[offsetMethod]().top + offsetBase,
targetSelector
]
}
}
return null
})
@@ -198,7 +201,7 @@ const ScrollSpy = (($) => {
_getOffsetHeight() {
return this._scrollElement === window ?
window.innerHeight : this._scrollElement.offsetHeight
window.innerHeight : this._scrollElement.getBoundingClientRect().height
}
_process() {