-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature: select tool extension feature #46
Conversation
|
export class FakeMouseEvent extends MouseEvent { | ||
constructor(type: string, values: MouseEventWithOffsets) { | ||
const { pageX, pageY, offsetX, offsetY, x, y, ...mouseValues } = values; | ||
super(type, mouseValues); | ||
|
||
Object.assign(this, { | ||
offsetX: offsetX || 0, | ||
offsetY: offsetY || 0, | ||
pageX: pageX || 0, | ||
pageY: pageY || 0, | ||
x: x || 0, | ||
y: y || 0, | ||
}); | ||
} | ||
} |
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.
Creating an event class for simulation purposes is impressive.
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.
Yes, the basic jest mouse event does not have offsetX or offsetY!
The solution was brought from testing-library/react-testing-library#268
export const getRelativeCornerWordPosOfPixelToOrigin = ( | ||
// the pixelIndex passed as a parameter should be an integer | ||
pixelIndex: { | ||
rowIndex: number; | ||
columnIndex: number; | ||
}, | ||
originPixelIndex: { rowIndex: number; columnIndex: number }, | ||
gridSquareLength: number, | ||
) => { | ||
// it will return world pos relative to originpixel word pos | ||
// the origin will be set to 0,0 |
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.
export const getRelativeCornerWordPosOfPixelToOrigin = ( | |
// the pixelIndex passed as a parameter should be an integer | |
pixelIndex: { | |
rowIndex: number; | |
columnIndex: number; | |
}, | |
originPixelIndex: { rowIndex: number; columnIndex: number }, | |
gridSquareLength: number, | |
) => { | |
// it will return world pos relative to originpixel word pos | |
// the origin will be set to 0,0 | |
/** | |
* @summary it will return world pos relative to originpixel word pos, the origin will be set to 0,0 | |
* @param pixelIndex - the pixelIndex passed as a parameter should be an integer | |
*/ | |
export const getRelativeCornerWordPosOfPixelToOrigin = ( | |
pixelIndex: { | |
rowIndex: number; | |
columnIndex: number; | |
}, | |
originPixelIndex: { rowIndex: number; columnIndex: number }, | |
gridSquareLength: number, | |
) => { |
how about using jsDoc tags for annotations? |
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.
From now on, I will try to use jsDoc tags as much as possible
getExtendingSelectedArea() { | ||
return this.extendingSelectedArea; | ||
} | ||
|
||
getExtendingSelectedPixels() { | ||
return this.extendingSelectedPixels; | ||
} |
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.
how about adding these to storybook example? let's show off great feature
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 will add an example for this in another PR later!
SonarCloud Quality Gate failed. 0 Bugs 68.1% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
🚀 [Related Issue: #43]
Preview
Screen.Recording.2023-07-08.at.8.58.01.AM.mov
Changes
Allow extension (sideways & diagonally) for selected area
[🎨Component] Detect extension direction for selected area
[🎨Component] Add algorithm for extending the selected area
originPixelIndex
and made each pixel in the area to extend according to the distance with the originPixelIndex.getOverlappingPixelIndicesForModifiedPixels
to check how I made the algorithm to find the pixels to color for the extended areadotting/src/utils/position.ts
Lines 465 to 531 in ab97c6b
[🎨Component] Add event listeners for key down and key up
dotting/src/components/Dotting.tsx
Lines 596 to 615 in ab97c6b
[🔗Other] Add tests for extension select area
dotting/src/utils/testUtils.ts
Lines 1 to 25 in ab97c6b
dotting/src/test/interactionLayer/select.test.tsx
Lines 7 to 78 in ab97c6b
Notes
Next Up?