diff --git a/assets/scripts/utils/transform.js b/assets/scripts/utils/transform.js index 3794524..0285664 100644 --- a/assets/scripts/utils/transform.js +++ b/assets/scripts/utils/transform.js @@ -4,32 +4,32 @@ * @return {number|object} translate value */ -const getTranslate = $el => { - - if(!window.getComputedStyle) { +const getTranslate = ($el) => { + if (!window.getComputedStyle) { return } let translate const style = getComputedStyle($el) - const transform = style.msTransform || style.webkitTransform || style.MozTransform || style.OTransform || style.transform + const transform = + style.msTransform || + style.webkitTransform || + style.MozTransform || + style.OTransform || + style.transform const matrix3D = transform.match(/^matrix3d\((.+)\)$/) - if(matrix3D) { + if (matrix3D) { translate = parseFloat(matrix3D[1].split(', ')[13]) } else { const matrix = transform.match(/^matrix\((.+)\)$/) translate = { x: matrix ? parseFloat(matrix[1].split(', ')[4]) : 0, - y: matrix ? parseFloat(matrix[1].split(', ')[5]) : 0 + y: matrix ? parseFloat(matrix[1].split(', ')[5]) : 0, } } return translate } - -export { - transform, - getTranslate -} +export { transform, getTranslate }