New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(Path, Polyline): BREAKING Svg import - cleanup #8857
Conversation
Build Stats
|
src/shapes/Polyline.ts
Outdated
'left', | ||
'top' | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to unwind setBoundingBox in order to apply the correct code or i should have had setBoundingBox returning a point like path does, but if i remember correctly that is not something we want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really not to sit down and look at open PRs
I believe I fixed this somewhere already
@ShaMan123 i merged the other PR on which there wasn't much to say. But if you can look at this we can see how we see this fix and if we want to open a task for a better fix. |
Did you try #8438? |
That seems to me only addressing the non nice code of a setDimension returning a point, that is tangential at the issue here that we are setting the point in the wrong position when originX and originY are different from top/left. It also doens't fix polygon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me check something
src/shapes/Path.ts
Outdated
if (this.fromSVG) { | ||
// if coming from SVG just assign top and left, those will be fixed | ||
// later by remove removeTransformMatrixForSvgParsing using the weird | ||
// _findCenterFromElement. | ||
// This is not clear and is probably wrong, but as of now it works in conjuction | ||
// with that other parsing function | ||
this.set({ left: pathTL.x, top: pathTL.y }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this.
Can we instead handle the logic in fromElement
and set the origin to left/top. Then prev logic should work
src/shapes/Polyline.ts
Outdated
this.set({ | ||
left: calculatedLeft, | ||
top: calculatedTop, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
should be handled by fromElement
Especially since we want some day to extract all SVG logic to a standalone
src/shapes/Polyline.ts
Outdated
'left', | ||
'top' | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really not to sit down and look at open PRs
I believe I fixed this somewhere already
It does fix this so it seems, the car test is flawless |
Should should be closed in favor of #8438 |
I am not sure the test in #8438 covers what you have found , please double check with origin |
I am thinking that originX/Y of a parsed path under a group should always be left/top regardless of anything |
No because that is a constrain that doesn't make sense. Is arbitrary. The only thing that should do is look as the SVG. You can't then work with objects that have different origins just because some come from SVG. I will look and see if i can move the fix logic inside the fromElement, unless is too much extra code because i have basically redo what i do in constructor but in fromElement too. The correct fix is probably in removeTransformMatrix code, but can't leave this broken too long. |
Try this to do what? what should i try? |
This half-way fix seems shaping better, but breaks gradients ( and probably patterns ). |
Need to understand if the breakage of unit tests i have now are because tests are now wrong or if this is still wrong.
|
Yes, all the test failing have |
Also Rect, Circle, Ellipse and Text are probably wrong when positioned from |
test the |
Sounds good. Take into consideration that stroke offset correction will die out with #8767 |
Ok at this point this is ready for me. |
Added small test that position polygon/path on a grid |
@ShaMan123 in the test there is a green line, that is there to represent how broken is the line currently, and that probably will be fixed with the line clean up. |
I won't do anything anymore here unless there are comment to address |
Those changes overlap with the SVG parse fromElement from callback to promise. |
Well done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
|
||
var polygon = new fabric.Polygon(getPoints(), { strokeWidth: 2, originX: 'left', originY: 'top' }); | ||
|
||
assert.equal(polygon.left, 9); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh snapshot testing, I wish you were here!!
Motivation
After fixing and investigating why SVG import was broken in #8879, a cleanup possibility was found.
We can remove the specific fromSVG import flag and the stroke offset correction from path parsing
Changes
creating Path/Polyon/Polyline with fromElement OUTSIDE the full svg parsing module will create different positioning, that is the same positioning that you would get using the constructor since now there is no more difference.
Is a breaking change, even if a good one in theory.
fromSVG one shot property is no more needed and is removed