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 customId for for animated movements and don't trigger movement when it isn't necessary #5

Merged
merged 2 commits into from
May 31, 2023

Conversation

rorystephenson
Copy link
Contributor

Adding an optional customId allows users to change the TileLayer's tileUpdateTransformer behaviour based on what triggers an animated movement.

In passing I noticed that it was possible to optimise the movement such that no calls to the MapController are made if no movement occurs and if both movement/rotation occur the MapControllers moveAndRotate method is used which is more efficient than calling both move() and rotate().

I also added a check to make sure that if we animate movement that we don't repeat the last movement (when animation.value == 1.0) and that we use the AnimatedMoveId.finish id exactly once.


Note in working on this I noticed a bug in my work for flutter_map 4.0.0 that actually breaks tileUpdateTransformers. The fix is merged in to master (fleaflet/flutter_map#1534) which will be released in 4.0.0. If it's helpful I have a branch on my own fork to apply it to 4.0.0: https://github.com/rorystephenson/flutter_map/tree/map-id-fix


Don't hesitate to modify/remove my changes if you don't like them. The reduced calls to MapController is actually technically a breaking change.

…en it isn't necessary

Adding an optional customId allows users to change the TileLayer's
tileUpdateTransformer behaviour based on what triggers an animated
movement.

In passing I noticed that it was possible to optimise the movement such
that no calls to the MapController are made if no movement occurs and if
both movement/rotation occur the MapControllers moveAndRotate method is
used which is more efficient than calling both move() and rotate().

I also added a check to make sure that if we animate movement that we
don't repeat the last movement (when animation.value == 1.0) and that we
use the AnimatedMoveId.finish id exactly once.
Copy link
Owner

@TesteurManiak TesteurManiak left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution, imo the breaking changes are not that big, I'll release a new version of the package alongside the new major flutter_map version.

lib/src/animated_map_controller.dart Outdated Show resolved Hide resolved
lib/src/animation_id.dart Outdated Show resolved Hide resolved
@TesteurManiak TesteurManiak self-assigned this May 30, 2023
@TesteurManiak TesteurManiak added the enhancement New feature or request label May 30, 2023
@rorystephenson
Copy link
Contributor Author

PR comments addressed 🙂.

@TesteurManiak TesteurManiak merged commit 224fb47 into TesteurManiak:main May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants