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

Remove resize listener action #4262

Merged
merged 2 commits into from
Mar 7, 2024
Merged

Conversation

briangregoryholmes
Copy link
Contributor

@briangregoryholmes briangregoryholmes commented Mar 7, 2024

This PR removes the createResizeListenerFactory module used in various places across the codebase as use:listenToNodeResize. In all instances, this action was used to capture the dimensions of an underlying DOM element. However, Svelte provides a native binding for this (bind:clientHeight and bind:clientWidth) and this PR replaces usage of the action with this binding.

While the Svelte binding has slightly more overhead than ResizeObserver, I propose making this change because it is used so infrequently throughout our codebase, removes the need for creating a store for the observed element, and the native binding will be updated to use ResizeObserver in Svelte 5 (sveltejs/svelte#7583).

That said, we could also replace this with bind:borderBoxSize, which uses the ResizeObserver API already, though it is slightly less ergonomic.

This PR also removes the getEltSize function, which was only used in the Dashboard component and captured the total size of an element including margin. However, the element it was applied to does not have margin to account for.

In a few instances, knowing the dimension of the element is not necessary, but I'll address that in a separate PR.

@briangregoryholmes briangregoryholmes self-assigned this Mar 7, 2024
@briangregoryholmes briangregoryholmes marked this pull request as ready for review March 7, 2024 04:39
Copy link
Contributor

@ericpgreen2 ericpgreen2 left a comment

Choose a reason for hiding this comment

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

Very much like this line of thinking 👍

@briangregoryholmes briangregoryholmes merged commit 74a162f into main Mar 7, 2024
4 checks passed
@briangregoryholmes briangregoryholmes deleted the bgh/remove-resize-listener branch March 7, 2024 14:41
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.

2 participants