license /** Parses a CSS time value to milliseconds. */ function parseCssTimeUnitsToMs ( value ) { const multiplier = value . toLowerCase ( ) . indexOf ( 'ms' ) > - 1 ? 1 : 1000 ; return parseFloat ( value ) * multiplier ; } /** Gets the transform transition duration, including the delay, of an element in milliseconds. */ export function getTransformTransitionDurationInMs ( element ) { const computedStyle = getComputedStyle ( element ) ; const transitionedProperties = parseCssPropertyValue ( computedStyle , 'transition-property' ) ; const property = transitionedProperties . find ( prop => prop === 'transform' || prop === 'all' ) ; if ( ! property ) { return 0 ; } const propertyIndex = transitionedProperties . indexOf ( property ) ; const rawDurations = parseCssPropertyValue ( computedStyle , 'transition-duration' ) ; const rawDelays = parseCssPropertyValue ( computedStyle , 'transition-delay' ) ; return parseCssTimeUnitsToMs ( rawDurations [ propertyIndex ] ) + parseCssTimeUnitsToMs ( rawDelays [ propertyIndex ] ) ; } /** Parses out multiple values from a computed style into an array. */ function parseCssPropertyValue ( computedStyle , name ) { const value = computedStyle . getPropertyValue ( name ) ; return value . split ( ',' ) . map ( part => part . trim ( ) ) ; }