Skip to content
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

Merged
merged 12 commits into from
Sep 26, 2023

Conversation

KonstantinEpam23
Copy link
Collaborator

@KonstantinEpam23 KonstantinEpam23 commented Sep 5, 2023

How the feature works? / How did you fix the issue?

Screen.Recording.2023-09-11.at.15.23.31.mov

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

@KonstantinEpam23 KonstantinEpam23 self-assigned this Sep 5, 2023
@KonstantinEpam23
Copy link
Collaborator Author

KonstantinEpam23 commented Sep 7, 2023

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: 3129-full-template-preview-following-mouse-cursor-draft-3

@KonstantinEpam23 KonstantinEpam23 force-pushed the 3129-full-template-preview-following-mouse-cursor branch from 62d6aca to 34cd4d3 Compare September 7, 2023 10:03
@AKZhuk AKZhuk linked an issue Sep 11, 2023 that may be closed by this pull request
@AKZhuk AKZhuk changed the title [DRAFT] #3129 - Full template preview following mouse cursor #3129 - Full template preview following mouse cursor Sep 11, 2023
@AKZhuk AKZhuk force-pushed the 3129-full-template-preview-following-mouse-cursor branch from 9b2669c to 6348557 Compare September 12, 2023 06:08
@Nitvex Nitvex marked this pull request as ready for review September 20, 2023 11:46
import { getAngleFromEvent, getBondFlipSign } from './template';

const PREVIEW_DELAY = 300;
type CiType = { map: string; id: number; dist: number };
Copy link
Collaborator

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?

@Zhirnoff
Copy link
Collaborator

16 tests fail. Please add screenshots of local run

Copy link
Collaborator

@rrodionov91 rrodionov91 left a 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

@Zhirnoff
Copy link
Collaborator

Pre-tested. Bug is fixed. And fixed comments added by @rrodionov91

Comment on lines +120 to +134
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);
Copy link
Collaborator

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;
Copy link
Collaborator

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();
Copy link
Collaborator

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

Comment on lines 107 to 111
const shouldHidePreview =
isMouseAwayFromAtomsAndBonds || isPreviewTargetChanged;

const shouldShowPreview =
ci && !this.connectedPreviewAction && !this.connectedPreviewTimeout;
Copy link
Collaborator

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

Comment on lines 125 to 135
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);
}
Copy link
Collaborator

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()

@Nitvex Nitvex merged commit 9cbf54b into master Sep 26, 2023
@Nitvex Nitvex deleted the 3129-full-template-preview-following-mouse-cursor branch September 26, 2023 15:40
SashaGraves pushed a commit that referenced this pull request Sep 28, 2023
* #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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Full template preview following mouse cursor
6 participants