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

Capture initial resize event #2552

Merged
merged 10 commits into from
May 19, 2023

Conversation

birkskyum
Copy link
Member

Closes #2551

Captures the initial resize event from the resize observer, so it's more similar to the previous implementation that didn't fire on setup.

Adds the browser test that checks that the 'load' event comes before 'resize' and 'moveend'

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!

@birkskyum birkskyum changed the title Capture initial resize event not done - Capture initial resize event May 18, 2023
@HarelM
Copy link
Collaborator

HarelM commented May 19, 2023

Seems like our unit tests are covering is 😀
I guess there's a need to add another call to trigger the observer. But this test can remain to make sure resize doesn't get called on first event.

@birkskyum birkskyum changed the title not done - Capture initial resize event Capture initial resize event May 19, 2023
@birkskyum
Copy link
Member Author

Updated the unit test to observe twice

// Call twice, because the initial "observe" event fired by ResizeObserver
// is muted in the map constructor

observerCallback();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add another test or and expectations between the first and second callback?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great idea, I added these so it now says:

            // The initial "observe" event fired by ResizeObserver should be captured/muted
            // in the map constructor

            observerCallback();
            expect(spyA).not.toHaveBeenCalled();
            expect(spyB).not.toHaveBeenCalled();

            // Following "observe" events should fire a resize / _update

            observerCallback();
            expect(spyA).toHaveBeenCalled();
            expect(spyB).toHaveBeenCalled();
            ```

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.

moveend is fired without a reason due to resize observer
2 participants