@@ -12,6 +12,7 @@ import {
1212 getSVGMatrix , getBodyOffset , getAbsoluteMatrix ,
1313} from "../utils" ;
1414import { getDocumentBody , getDocumentElement } from "@daybrush/utils" ;
15+ import { parseMat } from "css-to-mat" ;
1516
1617
1718export function getShadowRoot ( parentElement : HTMLElement | SVGElement ) {
@@ -60,6 +61,8 @@ export function getMatrixStackInfo(
6061 const getStyle = getCachedStyle ( el ) ;
6162 const position = getStyle ( "position" ) ;
6263 const scale = getStyle ( "scale" ) as string ;
64+ const rotate = getStyle ( "rotate" ) as string ;
65+ const translate = getStyle ( "translate" ) as string ;
6366 const transform = getElementTransform ( el ) ;
6467 const isFixed = position === "fixed" ;
6568 let matrix : number [ ] = convertCSStoMatrix ( getTransformMatrix ( transform ) ) ;
@@ -203,13 +206,18 @@ export function getMatrixStackInfo(
203206 matrix : getAbsoluteMatrix ( matrix , n , origin ) ,
204207 } ) ;
205208
206- if ( scale && scale !== "1" && scale !== "none" ) {
207- const [
208- scaleX ,
209- scaleY = scaleX ,
210- ] = scale . split ( " " ) . map ( scale => parseFloat ( scale ) ) as number [ ] ;
211- const scaleMatrix = createScaleMatrix ( [ scaleX , scaleY ] , n ) ;
209+ const individualTransforms : string [ ] = [ ] ;
212210
211+ if ( translate && translate !== "0px" && translate !== "none" ) {
212+ individualTransforms . push ( `translate(${ translate . split ( / \s + / ) . join ( "," ) } )` ) ;
213+ }
214+ if ( rotate && rotate !== "1" && rotate !== "none" ) {
215+ individualTransforms . push ( `rotate(${ rotate } )` ) ;
216+ }
217+ if ( scale && scale !== "1" && scale !== "none" ) {
218+ individualTransforms . push ( `scale(${ scale . split ( / \s + / ) . join ( "," ) } )` ) ;
219+ }
220+ if ( individualTransforms . length ) {
213221 matrixes . push ( {
214222 type : "offset" ,
215223 target : el ,
@@ -219,7 +227,7 @@ export function getMatrixStackInfo(
219227 matrixes . push ( {
220228 type : "target" ,
221229 target : el ,
222- matrix : getAbsoluteMatrix ( scaleMatrix , n , origin ) ,
230+ matrix : getAbsoluteMatrix ( parseMat ( individualTransforms ) , n , origin ) ,
223231 } ) ;
224232 }
225233 if ( hasOffset ) {
0 commit comments