How force Fabric.js polygon to update his points correctly after modify #10428
Unanswered
TheSinOfGreed
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’m using the latest version of Fabric.js, and I have a problem with a polygon. As we know, in Fabric.js, the points field of a polygon doesn’t update after modification (it always contains the initial points).
I want to recalculate the polygon's points after modification to get the current position of each point. To achieve this, I use the trick with calcTransformMatrix (the points are calculated correctly), and then I assign the new points to the existing polygon.
The problem occurs when I try to scale or rotate a polygon with updated points—this leads to crashes and bugs, and I don’t know why.
Here is demo code:
https://codesandbox.io/p/devbox/vibrant-kowalevski-v8vkjk?workspaceId=ws_JP9WoSuC2iw5iMuNawSDEv
After dragging, when we try to scale or rotate, we can see weird behavior.
I expect that after updating the points, rotating or scaling should not break the polygon.
If you try scale/rotate after drag (so after update points) you will see crashes.
Before drag (before points update):
After drag & scale/rotate or just scale/rotate:
Beta Was this translation helpful? Give feedback.
All reactions