}
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)
const scrollDiv = document.createElement('div')
scrollDiv.className = ClassName.SCROLLBAR_MEASURER
document.body.appendChild(scrollDiv)
- const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
+ const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth
document.body.removeChild(scrollDiv)
return scrollbarWidth
}
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
})
_getOffsetHeight() {
return this._scrollElement === window ?
- window.innerHeight : this._scrollElement.offsetHeight
+ window.innerHeight : this._scrollElement.getBoundingClientRect().height
}
_process() {