-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
fix(ActiveSelection): make sure canvas is in charge of setting initial coords #9322
Changes from 6 commits
8641496
30b5bfb
828b2d7
e23ecbd
de8afbb
14901f6
1955e43
1610882
2bc75a2
dca03c8
55aa08f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { Canvas } from '../canvas/Canvas'; | ||
import { ActiveSelection } from './ActiveSelection'; | ||
import { FabricObject } from './Object/FabricObject'; | ||
|
||
|
@@ -55,4 +56,20 @@ describe('ActiveSelection', () => { | |
selection.add(new FabricObject({ left: 50, top: 50, strokeWidth: 0 })); | ||
expect(selection.item(0).getCenterPoint()).toEqual({ x: 50, y: 50 }); | ||
}); | ||
|
||
it('sets coords after attaching to canvas', () => { | ||
const canvas = new Canvas(null, { | ||
activeSelection: new ActiveSelection([ | ||
new FabricObject({ | ||
left: 100, | ||
top: 100, | ||
width: 100, | ||
height: 100, | ||
}), | ||
]), | ||
viewportTransform: [2, 0, 0, 0.5, 400, 150], | ||
}); | ||
expect(canvas.getActiveSelection().getCoords()).toMatchSnapshot(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's test by picking aCoords and lineCoords that is what are we testing today. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
They are not recalcuated. I just have in mind #8767 so I avoid lineCoords already but whatever There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they are not recalculated no, but no one knows it, is not written the test is not explcit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not follow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh i thought you changed because i have seen outdated tag on the discussion |
||
expect(canvas.getActiveSelection().getCoords(true)).toMatchSnapshot(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ActiveSelection sets coords after attaching to canvas 1`] = ` | ||
[ | ||
Point { | ||
"x": 600, | ||
"y": 200, | ||
}, | ||
Point { | ||
"x": 802, | ||
"y": 200, | ||
}, | ||
Point { | ||
"x": 802, | ||
"y": 250.5, | ||
}, | ||
Point { | ||
"x": 600, | ||
"y": 250.5, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`ActiveSelection sets coords after attaching to canvas 2`] = ` | ||
[ | ||
Point { | ||
"x": 100, | ||
"y": 100, | ||
}, | ||
Point { | ||
"x": 201, | ||
"y": 100, | ||
}, | ||
Point { | ||
"x": 201, | ||
"y": 201, | ||
}, | ||
Point { | ||
"x": 100, | ||
"y": 201, | ||
}, | ||
] | ||
`; |
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.
Isn't this a canvas test? is the canvas executing the new code no?
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.
true, I have no idea where it should belong