fix box sizing calculations
This commit is contained in:
parent
e65087e8d1
commit
cef354d412
|
@ -15,9 +15,18 @@ function assign (ta) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let heightOffset = null
|
||||||
let cachedHeight = null
|
let cachedHeight = null
|
||||||
|
|
||||||
function init () {
|
function init () {
|
||||||
|
const style = window.getComputedStyle(ta, null)
|
||||||
|
|
||||||
|
if (style.boxSizing === 'content-box') {
|
||||||
|
heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom))
|
||||||
|
} else {
|
||||||
|
heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth)
|
||||||
|
}
|
||||||
|
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +42,7 @@ function assign (ta) {
|
||||||
|
|
||||||
ta.style.height = ''
|
ta.style.height = ''
|
||||||
|
|
||||||
let endHeight = ta.scrollHeight
|
let endHeight = ta.scrollHeight + heightOffset
|
||||||
|
|
||||||
if (ta.scrollHeight === 0) {
|
if (ta.scrollHeight === 0) {
|
||||||
// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
|
// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
|
||||||
|
|
Loading…
Reference in a new issue