chrvadala/transformation-matrix

Uncaught Error: 'matrix(1, 0, 0, 1, 0, -6.6763e-06)' is not a matrix

pinyin opened this issue · 5 comments

Chrome sometimes return transform matrix in an exponential notation, e.g. -6.6763e-06 in this case.
Is this not supported?

I'm not sure that you're talking about the parse ability but in that case unfortunately is not supported

Yes, I was talking about the fromString utility, sorry for the ambiguity.
Thanks for your work.

The problem is in this line

const matrixRegex = /^matrix\(\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*\)$/i;

That regex doesn't support number in that format

You can provide a different Regex to support number formatted in that way.
I think that you can change (-?[0-9]*\.?[0-9]+) with ([0-9e-]+), but I'm not sure that it's enough safe

OK, I'll try that. Thanks!

Fixed with 1.8.0