mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-25 12:22:50 +01:00
HTMLElement.offset* by getBoundingClientRect() (#21788)
* Replace element.offet* by getBoundingClientRect() * Use variable to store BoundingClientRect * Fix cc issue...
This commit is contained in:
parent
f2f2e39a45
commit
275821bbb0
@ -211,10 +211,8 @@ const Collapse = (($) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dimension = this._getDimension()
|
const dimension = this._getDimension()
|
||||||
const offsetDimension = dimension === Dimension.WIDTH ?
|
|
||||||
'offsetWidth' : 'offsetHeight'
|
|
||||||
|
|
||||||
this._element.style[dimension] = `${this._element[offsetDimension]}px`
|
this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`
|
||||||
|
|
||||||
Util.reflow(this._element)
|
Util.reflow(this._element)
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ const Modal = (($) => {
|
|||||||
const scrollDiv = document.createElement('div')
|
const scrollDiv = document.createElement('div')
|
||||||
scrollDiv.className = ClassName.SCROLLBAR_MEASURER
|
scrollDiv.className = ClassName.SCROLLBAR_MEASURER
|
||||||
document.body.appendChild(scrollDiv)
|
document.body.appendChild(scrollDiv)
|
||||||
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
|
const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth
|
||||||
document.body.removeChild(scrollDiv)
|
document.body.removeChild(scrollDiv)
|
||||||
return scrollbarWidth
|
return scrollbarWidth
|
||||||
}
|
}
|
||||||
|
@ -133,12 +133,15 @@ const ScrollSpy = (($) => {
|
|||||||
target = $(targetSelector)[0]
|
target = $(targetSelector)[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target && (target.offsetWidth || target.offsetHeight)) {
|
if (target) {
|
||||||
// todo (fat): remove sketch reliance on jQuery position/offset
|
const targetBCR = target.getBoundingClientRect()
|
||||||
return [
|
if (targetBCR.width || targetBCR.height) {
|
||||||
$(target)[offsetMethod]().top + offsetBase,
|
// todo (fat): remove sketch reliance on jQuery position/offset
|
||||||
targetSelector
|
return [
|
||||||
]
|
$(target)[offsetMethod]().top + offsetBase,
|
||||||
|
targetSelector
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
@ -198,7 +201,7 @@ const ScrollSpy = (($) => {
|
|||||||
|
|
||||||
_getOffsetHeight() {
|
_getOffsetHeight() {
|
||||||
return this._scrollElement === window ?
|
return this._scrollElement === window ?
|
||||||
window.innerHeight : this._scrollElement.offsetHeight
|
window.innerHeight : this._scrollElement.getBoundingClientRect().height
|
||||||
}
|
}
|
||||||
|
|
||||||
_process() {
|
_process() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user