-
Notifications
You must be signed in to change notification settings - Fork 187
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
#3129 - Full template preview following mouse cursor #3252
#3129 - Full template preview following mouse cursor #3252
Conversation
The current issue is that after selecting the template - if the user presses undo - the template preview will be left on the canvas instead of hiding the preview and undoing the last action. I have started re-doing the approach in branch: |
62d6aca
to
34cd4d3
Compare
9b2669c
to
6348557
Compare
…ll-template-preview-following-mouse-cursor
import { getAngleFromEvent, getBondFlipSign } from './template'; | ||
|
||
const PREVIEW_DELAY = 300; | ||
type CiType = { map: string; id: number; dist: number }; |
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.
What's "ci"? Maybe we can use the full name?
16 tests fail. Please add screenshots of local run |
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.
Please check this behaviour. Looks like bugs.
Screen.Recording.2023-09-21.at.13.44.37.mov
Screen.Recording.2023-09-21.at.13.41.08.mov
Screen.Recording.2023-09-21.at.13.32.29.mov
…ll-template-preview-following-mouse-cursor
…ll-template-preview-following-mouse-cursor
Pre-tested. Bug is fixed. And fixed comments added by @rrodionov91 |
const bondId = 2; | ||
const shift = 100; | ||
await selectRingButton(RingButton.Benzene, page); | ||
const bondPosition = await getBondByIndex( | ||
page, | ||
{ type: BondType.SINGLE }, | ||
bondId, | ||
); | ||
const pointAwayFromBond = { | ||
x: bondPosition.x + shift, | ||
y: bondPosition.y + shift, | ||
}; | ||
await takeEditorScreenshot(page); | ||
await page.mouse.move(pointAwayFromBond.x, pointAwayFromBond.y); | ||
await takeEditorScreenshot(page); |
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 believe that this test covers the case from the previous one and we can keep just only this test.
class TemplatePreview { | ||
private readonly editor: Editor; | ||
private readonly template; | ||
private readonly mode: 'fg' | null; |
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 believe we can have more clear values for "mode".
movePreview(event: PointerEvent) { | ||
this.position = this.editor.render.page2obj(event); | ||
|
||
const ci = this.getPreviewTarget(); |
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 would propose to rename ci to previewTarget
const shouldHidePreview = | ||
isMouseAwayFromAtomsAndBonds || isPreviewTargetChanged; | ||
|
||
const shouldShowPreview = | ||
ci && !this.connectedPreviewAction && !this.connectedPreviewTimeout; |
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 would propose to rename it to shouldHideConnectedPreview and shouldShowConnectedPreview
if (!this.floatingPreview) { | ||
this.showFloatingPreview(this.position); | ||
this.previousPosition = this.position; | ||
this.editor.render.update(false, null, { resizeCanvas: false }); | ||
} else { | ||
const dist = this.position.sub(this.previousPosition); | ||
this.previousPosition = this.position; | ||
fromMultipleMove(this.restruct, this.floatingPreview, dist); | ||
this.editor.render.update(false, null, { resizeCanvas: false }); | ||
this.hoverFusedItems(ci, event); | ||
} |
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 would propose to move it to separate function f.e. moveFloatingPreview()
* #3129 - Full template preview following mouse cursor: draft 4 * #3129 - Full template preview following mouse cursor * #3129 - Full template preview following mouse cursor - Fix e2e * #3129 – fixed showing preview for preview-bonds * #3129 – fixed position for preview * #3129 – fixed showing preview for functional groups * #3129 – fixed failing tests * #3129 – fixed failing tests * #3129 – refactor after review --------- Co-authored-by: Aliaksei <[email protected]> Co-authored-by: Nikita_Vozisov <[email protected]>
How the feature works? / How did you fix the issue?
Screen.Recording.2023-09-11.at.15.23.31.mov
Check list
#1234 – issue name