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

fix: [issue-2238] stop camera animation on mac when reduced motion is on #3068

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

sebastianoscarlopez
Copy link
Contributor

@sebastianoscarlopez sebastianoscarlopez commented Sep 10, 2023

To fix issue #2238, this PR modifies the camera animation behavior on Mac when the 'reduced motion' setting is on.

Explanation:

The camera.easeTo method is called after the map movement happens, in order to add if needed a kind of "inertia movement". The easeTo method is called with the around property option with the position that should be the end of the camera ease movement.
Currently, when the 'reduced motion' setting is on, the duration is changed by 0. This does not avoid the final result, it only avoids the animation, because the final result will be at the around position, so it looks like an unexpected jump.

Example of the current behaviour, another example can be found here #2238

issue-2238-main.mp4

Approaches to fix

  • My first approach was to just return this; if the reduced motion was on, but that approach didn't work well because it broke the zoom when the method was called by a double click.

  • Another approach can be to reassign the around property to the center, because as was said before the movement was already done, and the center is in the current position, so the following code in the method will try as usual to do a movement, but its start position will be equal to the end position, so no movement will occur at all.

  • This PR approach avoids calling this method when reduced motion is on

Result with this approach

issue-2238.mp4

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!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • 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.
  • Add an entry to CHANGELOG.md under the ## main section.

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (18dcac9) 75.06% compared to head (e41dc5b) 75.06%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3068   +/-   ##
=======================================
  Coverage   75.06%   75.06%           
=======================================
  Files         240      240           
  Lines       19134    19135    +1     
  Branches     4320     4320           
=======================================
+ Hits        14363    14364    +1     
  Misses       4771     4771           
Files Changed Coverage Δ
src/ui/handler_manager.ts 96.49% <100.00%> (+0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Sep 10, 2023

Can you elaborate why setting arond to center solves this issue?
Also can you add a before and after videos to better show the change/fix?
What will happen if the user uses easeTo not around the center with reduced motion? Is it a possibility?

@sebastianoscarlopez
Copy link
Contributor Author

Hi @HarelM, thanks for the feedback. The description was updated. While I was writing it, another approach came to my mind.
Please let me know your thoughts about it.

@HarelM
Copy link
Collaborator

HarelM commented Sep 11, 2023

I think I would like to avoid calling easeTo in case of reduced motion, seems cleaner to me...

@sebastianoscarlopez sebastianoscarlopez force-pushed the issue/2238 branch 2 times, most recently from 038a3f1 to b165fef Compare September 14, 2023 01:47
@sebastianoscarlopez
Copy link
Contributor Author

I think I would like to avoid calling easeTo in case of reduced motion, seems cleaner to me...

@HarelM as you said, avoiding easeTo (inertia animation) results in cleaner code.

note: some tests failed, but it seems like something unrelated to this pr.

@HarelM
Copy link
Collaborator

HarelM commented Sep 14, 2023

Unfortunately, the tests are flaky, not sure how to solve this... :-(
Can you add a unit test to make sure this behavior will not break in the future?
Otherwise, this looks great.

@sebastianoscarlopez sebastianoscarlopez marked this pull request as ready for review September 17, 2023 18:14
@sebastianoscarlopez
Copy link
Contributor Author

Now the test drag map check behavior with and without reduced motion feature

@HarelM
Copy link
Collaborator

HarelM commented Sep 19, 2023

Looks great and super clean, THANKS!

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.

3 participants