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

Add zoom functionality to wafermap #923

Merged
merged 20 commits into from
Jan 13, 2023

Conversation

arinluca333
Copy link
Contributor

Pull Request

🀨 Rationale

The wafer map needs to have a zoom functionality. This is provided by the d3 library.

πŸ‘©β€πŸ’» Implementation

Added a d3 zoom event on the canvas that modifies the transform of the zoom-container.

πŸ§ͺ Testing

Tested the change in the storybook and added test for where we simulate a zooming events.

βœ… Checklist

  • [ x] I have updated the project documentation to reflect my changes or determined no changes are needed.

@rajsite rajsite mentioned this pull request Jan 4, 2023
1 task
@jattasNI
Copy link
Contributor

@arinluca333 friendly reminder to click the "Re-request review" button for Milan and I when this is ready for us to take another look. That's the signal we'll use to know that you've addressed everything you plan to or you need more input from us.

@arinluca333
Copy link
Contributor Author

@arinluca333 friendly reminder to click the "Re-request review" button for Milan and I when this is ready for us to take another look. That's the signal we'll use to know that you've addressed everything you plan to or you need more input from us.

Thanks for the heads up!

packages/nimble-components/src/wafer-map/index.ts Outdated Show resolved Hide resolved
packages/nimble-components/src/wafer-map/styles.ts Outdated Show resolved Hide resolved
packages/nimble-components/src/wafer-map/template.ts Outdated Show resolved Hide resolved
arinluca333 and others added 3 commits January 12, 2023 09:58
Co-authored-by: Milan Raj <rajsite@users.noreply.github.com>
@@ -86,6 +93,9 @@ export class WaferMap extends FoundationElement {
this.canvasSideLength = Math.min(height, width);
});
this.resizeObserver.observe(this);
this.canvas.addEventListener('wheel', event => event.preventDefault(), {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this event listener in the disconnectedCallback, otherwise we'll end up with duplicate listeners if the same element is added, removed, and re-added to the page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arinluca333 I don't think the approach you used in removeEventListener() will work. I believe the add/remove functions track the listener function by reference. You're attempting to remove a new listener function which is a copy of the original one. So removeEventListener won't find any listener that matches it and will silently fail.

From the MDN docs:

Calling removeEventListener() with arguments that do not identify any currently registered event listener on the EventTarget has no effect.

Instead you need to save the event listener to a class member variable and pass that variable to both addEventListener and removeEventListener.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed #964 to you to track fixing this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the exact same function reference must be used, concretely (pseudocode):

class {
    private wheelHandler = () => {};

    connectedCallback() { this.canvas.addEventListener('wheel', wheelHandler);}
    disconnectedCallback() { this.canvas.removeEventListener('wheel', wheelHandler); }
}

@arinluca333 arinluca333 enabled auto-merge (squash) January 13, 2023 06:51
@arinluca333 arinluca333 merged commit 61ae65c into main Jan 13, 2023
@arinluca333 arinluca333 deleted the users/aluca/add-zoom-functionality-to-wafermap branch January 13, 2023 07:04
@vikisekarNI
Copy link
Contributor

Ignore the above mention. Was experimenting the PR tagging functionalities in GitHub

image

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.

6 participants