mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
Run precommit
This commit is contained in:
@@ -4,15 +4,19 @@
|
|||||||
* @return {number|object} translate value
|
* @return {number|object} translate value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const getTranslate = $el => {
|
const getTranslate = ($el) => {
|
||||||
|
|
||||||
if (!window.getComputedStyle) {
|
if (!window.getComputedStyle) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let translate
|
let translate
|
||||||
const style = getComputedStyle($el)
|
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\((.+)\)$/)
|
const matrix3D = transform.match(/^matrix3d\((.+)\)$/)
|
||||||
if (matrix3D) {
|
if (matrix3D) {
|
||||||
@@ -21,15 +25,11 @@ const getTranslate = $el => {
|
|||||||
const matrix = transform.match(/^matrix\((.+)\)$/)
|
const matrix = transform.match(/^matrix\((.+)\)$/)
|
||||||
translate = {
|
translate = {
|
||||||
x: matrix ? parseFloat(matrix[1].split(', ')[4]) : 0,
|
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
|
return translate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { transform, getTranslate }
|
||||||
export {
|
|
||||||
transform,
|
|
||||||
getTranslate
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user