-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Cancel active fling animation when appropriate #85
Conversation
Cool! Can you call this cancel() and cancel both STATE_FLINGING and STATE_ANIMATING ? Would this fit your requirements? Docs would say that this cancels any animated motion like flings or developer started animations, while of course pinch/scrolls can't be canceled because the finger is still there. Not against a more specific API but I think that all these names (scroll/pan/pinch/zoom/fling) in API and XML attributes are already confusing enough. A simple cancel() or cancelAnimations() would be better. |
Looking at the code now, I would also appreciate if you could simplify and remove the I mean that instead of checking |
It's funny because at first I also created a cancel flag for the fling 😄 But then I realized the state is also reflecting this and was used already to stop the fling in some situations. |
When I think about it, canceling ongoing animations from the update method isn't a good idea anyway because it might be possible to switch to a new animation while an old animation is still around. In that case the update method will certainly almost never reach it's |
Sorry, I understand this comment now! Need an extra check then... Maybe we could keep an Flings should not have this issue as they are started by input events and you can't have two at the same time |
removed mClearAnimation flag and replaced it with mActiveAnimators which holds a list of all active animators that will be cancelled if a new animation starts or the state changes for other reasons updated readme
aebc591
to
e6e251e
Compare
I would just keep a reference of all active animators and cancel them if necessary. EDIT: |
I created a new issue (#86) for the touch input stopping animations thing. |
README.md
Outdated
@@ -267,6 +268,7 @@ In any case the current scale is not considered, so your system won't change if | |||
|`setAllowFlingInOverscroll(boolean)`|If true, fling gestures will be allowed even when detected while overscrolled. This might cause artifacts so it is disabled by default.|`false`| | |||
|`panTo(float, float, boolean)`|Pans to the given values, animating if needed.|`-`| | |||
|`panBy(float, float, boolean)`|Applies the given deltas to the current pan, animating if needed.|`-`| | |||
|`cancelAnimations()`|Cancels all currently active code driven animations (including fling animations).|`-`| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say a finger fling is not code driven?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the user isn't touching the screen anymore so... I would argue it is 😄 but I see your point.
Do you have a suggestion? Would you just write:
Cancels all currently active animations.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be more specific and say like, animations triggered by API calls with animate = true
and fling animations triggered by touch input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@natario1 Ok with the current vesion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! @markusressel feel free to create a new release if you think so
I don't have a strong position about this, I'm OK with merging your autocancel, but yes, in theory we could avoid. If you run two animations, the second should win in the end - not sure about the eye result, but I think it should run after the first at each cycle, invalidating the first. You just get a mess of listener updates. For this the dev could call Buut again, not sure :-) Should we add an API like allowConcurrentAnimations ? Or, in the long run, have two booleans |
You're right, this would be impossible to handle properly if the dev is allowed to start multiple animations at the same time... I don't think this is a good thing to allow then. The only drawback with limiting to a single animation concurrently is that f.ex. a
I don't think so (based on the text above). |
added cancelFling method to ZoomApi
cancel fling in moveTo, panBy and zoomTo if necessary
fixes #84