chrvadala / transformation-matrix

Javascript isomorphic 2D affine transformations written in ES6 syntax. Manipulate transformation matrices with this totally tested library!

Home Page:https://www.npmjs.com/package/transformation-matrix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

pinyin opened this issue · 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