function getOuterWidth ( el , margin ? ) { let offsetWidth = el . offsetWidth ; if ( margin ) { const style = getComputedStyle ( el ) ; offsetWidth += parseFloat ( style . marginLeft ! ) + parseFloat ( style . marginRight ! ) ; } return offsetWidth ; } function innerWidth ( el ) { let offsetWidth = el . offsetWidth ; const style = getComputedStyle ( el ) ; offsetWidth += parseFloat ( style . paddingLeft ! ) + parseFloat ( style . paddingRight ! ) ; return offsetWidth ; } function width ( el ) { let offsetWidth = el . offsetWidth ; const style = getComputedStyle ( el ) ; offsetWidth -= parseFloat ( style . paddingLeft ! ) + parseFloat ( style . paddingRight ! ) ; return offsetWidth ; } function getInnerHeight ( el ) { let height = el . offsetHeight ; const style = getComputedStyle ( el ) ; height += parseFloat ( style . paddingTop ! ) + parseFloat ( style . paddingBottom ! ) ; return height ; } function getOuterHeight ( el , margin ? ) { let height = el . offsetHeight ; if ( margin ) { const style = getComputedStyle ( el ) ; height += parseFloat ( style . marginTop ! ) + parseFloat ( style . marginBottom ! ) ; } return height ; } function getHeight ( el ) { let height = el . offsetHeight ; const style = getComputedStyle ( el ) ; height -= parseFloat ( style . paddingTop ! ) + parseFloat ( style . paddingBottom ! ) + parseFloat ( style . borderTopWidth ! ) + parseFloat ( style . borderBottomWidth ! ) ; return height ; } function getWidth ( el ) { let offsetWidth = el . offsetWidth ; const style = getComputedStyle ( el ) ; offsetWidth -= parseFloat ( style . paddingLeft ! ) + parseFloat ( style . paddingRight ! ) + parseFloat ( style . borderLeftWidth ! ) + parseFloat ( style . borderRightWidth ! ) ; return offsetWidth ; } function scrollInView ( container , item ) { const borderTopValue = getComputedStyle ( container ) . getPropertyValue ( 'borderTopWidth' ) ; const borderTop = borderTopValue ? parseFloat ( borderTopValue ) : 0 ; const paddingTopValue = getComputedStyle ( container ) . getPropertyValue ( 'paddingTop' ) ; const paddingTop = paddingTopValue ? parseFloat ( paddingTopValue ) : 0 ; const containerRect = container . getBoundingClientRect ( ) ; const itemRect = item . getBoundingClientRect ( ) ; const offset = ( itemRect . top + document . body . scrollTop ) - ( containerRect . top + document . body . scrollTop ) - borderTop - paddingTop ; const scroll = container . scrollTop ; const elementHeight = container . clientHeight ; const itemHeight = getOuterHeight ( item ) ; if ( offset < 0 ) { container . scrollTop = scroll + offset ; } else if ( ( offset + itemHeight ) > elementHeight ) { container . scrollTop = scroll + offset - elementHeight + itemHeight ; } } function getElementLeft ( element ) { let actualLeft = element . offsetLeft ; let current = element . offsetParent ; while ( current !== null ) { actualLeft += current . offsetLeft ; current = current . offsetParent ; } return actualLeft ; } function getElementTop ( element ) { let actualTop = element . offsetTop ; let current = element . offsetParent ; while ( current !== null ) { actualTop += current . offsetTop ; current = current . offsetParent ; } return actualTop ; } export { getHeight , getInnerHeight , getOuterWidth , getOuterHeight , getWidth , innerWidth , scrollInView , width , getElementLeft , getElementTop , } ;