fix box sizing calculations

This commit is contained in:
Nolan Lawson 2018-02-25 23:01:15 -08:00
parent e65087e8d1
commit cef354d412
1 changed files with 10 additions and 1 deletions

View File

@ -15,9 +15,18 @@ function assign (ta) {
return
}
let heightOffset = null
let cachedHeight = null
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()
}
@ -33,7 +42,7 @@ function assign (ta) {
ta.style.height = ''
let endHeight = ta.scrollHeight
let endHeight = ta.scrollHeight + heightOffset
if (ta.scrollHeight === 0) {
// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.