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

Move blur event reset into non-touch handlers #11087

Merged
merged 4 commits into from
Oct 5, 2021

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Oct 5, 2021

Related to #11048, the tab bar toggle also emits a window blur event which interrupts interactions when the page is initially opened:

IMG_0104.mp4

Simply removing all blur handling has this effect on desktop, in which interactions continue after the window is backgrounded:

blur

The solution taken by this PR is to move a blur handler into individual non-touch handlers, so that blur events only reset non-touch events.

The main concern here is that we lose out on a couple things that the stop method does:

stop(allowEndAnimation: boolean) {
// do nothing if this method was triggered by a gesture update
if (this._updatingCamera) return;
for (const {handler} of this._handlers) {
handler.reset();
}
this._inertia.clear();
this._fireEvents({}, {}, allowEndAnimation);
this._changes = [];
}

Launch Checklist

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page
  • tagged @mapbox/map-design-team @mapbox/static-apis if this PR includes style spec API or visual changes
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog></changelog>

Copy link
Contributor

@ansis ansis left a comment

Choose a reason for hiding this comment

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

This looks good to me!

The main concern here is that we lose out on a couple things that the stop method does:

fireEvents still gets called later on if necessary and I don't think the inertia will cause any problems.

@rreusser rreusser merged commit 010c497 into mourner/fix-ios-15 Oct 5, 2021
@rreusser rreusser deleted the ricky/blur-fix branch October 5, 2021 21:27
rreusser added a commit that referenced this pull request Oct 5, 2021
* fix an iOS15 issue where map stops when panning

* fix tests and lint

* Test drag pan handler does not end interaction on resize

* Move blur event reset into non-touch handlers (#11087)

* Move blur event reset into non-touch handlers

* Fix linter

* Fix/amend unit tests

* Flush task queue in rotate test

Co-authored-by: Ricky Reusser <ricky.reusser@mapbox.com>
Co-authored-by: Ricky Reusser <rreusser@users.noreply.github.com>
rreusser added a commit that referenced this pull request Oct 5, 2021
* fix an iOS15 issue where map stops when panning

* fix tests and lint

* Test drag pan handler does not end interaction on resize

* Move blur event reset into non-touch handlers (#11087)

* Move blur event reset into non-touch handlers

* Fix linter

* Fix/amend unit tests

* Flush task queue in rotate test

Co-authored-by: Ricky Reusser <ricky.reusser@mapbox.com>
Co-authored-by: Ricky Reusser <rreusser@users.noreply.github.com>
rreusser added a commit that referenced this pull request Oct 6, 2021
…11089)

* fix an iOS15 issue where map stops when panning

* fix tests and lint

* Test drag pan handler does not end interaction on resize

* Move blur event reset into non-touch handlers (#11087)

* Move blur event reset into non-touch handlers

* Fix linter

* Fix/amend unit tests

* Flush task queue in rotate test

Co-authored-by: Ricky Reusser <ricky.reusser@mapbox.com>
Co-authored-by: Ricky Reusser <rreusser@users.noreply.github.com>

Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
avpeery pushed a commit that referenced this pull request Oct 6, 2021
…11089)

* fix an iOS15 issue where map stops when panning

* fix tests and lint

* Test drag pan handler does not end interaction on resize

* Move blur event reset into non-touch handlers (#11087)

* Move blur event reset into non-touch handlers

* Fix linter

* Fix/amend unit tests

* Flush task queue in rotate test

Co-authored-by: Ricky Reusser <ricky.reusser@mapbox.com>
Co-authored-by: Ricky Reusser <rreusser@users.noreply.github.com>

Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
avpeery added a commit that referenced this pull request Oct 7, 2021
…11101)

* Fix an iOS15 issue where Safari tab bar interrupts panning (#11084) (#11089)

* fix an iOS15 issue where map stops when panning

* fix tests and lint

* Test drag pan handler does not end interaction on resize

* Move blur event reset into non-touch handlers (#11087)

* Move blur event reset into non-touch handlers

* Fix linter

* Fix/amend unit tests

* Flush task queue in rotate test

Co-authored-by: Ricky Reusser <ricky.reusser@mapbox.com>
Co-authored-by: Ricky Reusser <rreusser@users.noreply.github.com>

Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>

* Removed getBoundingClientRect conflict for unit tests

* Added offsetHeight to replace getBoundingClientRect to fix unit tests

* add clientWidth and clientHeight to unit tests

* container -> map.getContainer()

* Replaced offsetWidth with clientWidth

* removing change difference in attribution and logo unit tests from v1.13.2

* Change size of container instead of canvas container to trigger resize in unit tests

* Added change in height to trigger resize

* fix to attribution.test.js

* Fixes logo.test.js to pass

* removed unneeded changes

Co-authored-by: Ricky Reusser <rreusser@users.noreply.github.com>
Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants