thednp / svg-path-commander

Typescript tools for advanced processing of SVG path data.
https://thednp.github.io/svg-path-commander/
MIT License
228 stars 19 forks source link

flipX - origin is not iterable: Related to using in Vue 3 component? #9

Closed brianakidd closed 2 years ago

brianakidd commented 2 years ago

I'm simply trying to execute the example code:

import SVGPathCommander from 'svg-path-commander';

const path = 'M0 0 L50 100';

const flippedPathString = new SVGPathCommander(path).flipX().toString();

but receive console error "origin is not iterable." Is this related to executing inside a Vue component? On the demo page (https://thednp.github.io/svg-path-commander/index.html), I can paste my data in, perform transformations, and receive expected output.

thednp commented 2 years ago

I'm not sure, but a test site would help. Might be related to an older version, you sure you're up to date?

Anyways, I'm planning to add Cypress testing suite to SVGPathCommander and remove any remaining bugs. Perhaps sooner than expected.

tombigel commented 2 years ago

@thednp I'm getting the same error, using the skypack version (https://www.skypack.dev/view/svg-path-commander)

The bug is in line 205 in svg-path-commander.js

If origin is not passed to any .transform() operation (also flipX/Y etc.) the transform function spreads origin to an object instead of an array -

 } else {
      transform.origin = {...this.origin};
    }

should be :

 } else {
      transform.origin = [...this.origin];
    }
tombigel commented 2 years ago

I created a pr https://github.com/thednp/svg-path-commander/pull/10

lordanubi commented 2 years ago

Having the same problem in React but this doesn't fix it:

 } else {
      transform.origin = [...this.origin];
    } 
thednp commented 2 years ago

@lordanubi have a minute to produce a test repo.

thednp commented 2 years ago

@brianakidd I can confirm the fix is solid for me. I'm ready to push v0.1.26 to the cloud.

V0.2.0 will feature Cypress testing.

brianakidd commented 2 years ago

@thednp Sounds great. Thanks

thednp commented 2 years ago

@lordanubi we're waiting for your confirmation.

thednp commented 2 years ago

@brianakidd @lordanubi @tombigel please test latest master and let me know how it goes, Cypress testing is added to the main class, later to add for all statics, have fun!

thednp commented 2 years ago

@brianakidd @lordanubi @tombigel should we close this?

lordanubi commented 2 years ago

I'm not getting the error anymore with last version but I noticed that flipX() and flipY() do the same thing have you checked that? Anyway thanks for your hard work! Keep it up :)

thednp commented 2 years ago

@lordanubi perhaps your shape is a square or a circle?

lordanubi commented 2 years ago

whooops sorry it was my setup buggin as fuck, it works like a charm! Thanks again you can definitely close this

tombigel commented 2 years ago

sorry, was on holiday.