-
Notifications
You must be signed in to change notification settings - Fork 8
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
JavaDoc #2
Comments
Yes! I totally agree. FWIW the JavaScript stuff I did for the UI physics writeup has basically the same interface and there are a bunch of examples for that: http://iamralpht.github.io/physics code: https://github.com/iamralpht/iamralpht.github.io/tree/master/physics I should wrap that up into a GravitasJS library, too. I haven't had time recently to do Gravitas justice on Android. I'd love to figure out if I could use a Gravitas physics model to drive one of the new structural transitions (activity->activity preserving some structure, like that music animation that keeps popping up, or like the new dialer) since it would be a good match for those that can be gesturally driven... |
Well I was looking at using it in Flow (by Square), But would require On Tue Dec 02 2014 at 6:27:02 PM Ralph Thomas [email protected]
|
Oh, that's easy enough to add; I'll try and schedule some time to put an example together. With some extra math we can figure out the duration of the simulations and make something that works as a TimeInterpolator in Android (it's a bit unnatural since for a spring you have to do a numerical analysis to find the duration, but it converges fast enough for typical UI animations [i.e.: not incredibly underdamped!]). The advantage is that it's then just a quick integration to whatever you're already doing and doesn't require replacing the whole animation system (ala rebound). |
That would be cool. On Tue, 2 Dec 2014 18:56 Ralph Thomas [email protected] wrote:
|
You mean you have a spring configuration where it takes ages to do the last pixel (or whatever you've mapped the spring to)? So it seems like the UI should be usable to the user, but they're still locked out because you're actually still transitioning the screen? I hit that in Letterplex in a few places (because it's endemic to springs) and "solved" it by saying "when the value is this close to the target, just make the next screen/whatever interactive already". So in Flow, you'd want to call |
This is currently what we do: @Override
public void createSegue(final ViewGroup container, @Nullable final View from, final View to, final Flow.Direction direction, final Flow.Callback callback) {
if (from == null) return;
final boolean backward = direction == Flow.Direction.BACKWARD;
mSpringFrom.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(final Spring spring) {
from.setTranslationX((float) spring.getCurrentValue());
}
@Override
public void onSpringAtRest(final Spring spring) {
container.removeView(from);
mSpringFrom.removeListener(this);
// We complete here as it's most important that the old ScopedView is removed.
callback.onComplete();
}
});
mSpringTo.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(final Spring spring) {
to.setTranslationX((float) spring.getCurrentValue());
}
@Override
public void onSpringAtRest(final Spring spring) {
mSpringTo.removeListener(this);
}
});
// Will always be on Screen
mSpringFrom.setCurrentValue(0);
// if backwards come from off screen left
mSpringTo.setCurrentValue(backward ? -to.getWidth() : to.getWidth());
// Move off screen
mSpringFrom.setEndValue(backward ? from.getWidth() : -from.getWidth());
// Move to on screen
mSpringTo.setEndValue(0);
} Alot to be desired. It needs to be a close to target, "resting" state. |
Project looks lovely and works nicely as seen in Letterplex.
Would be good to have more JavaDocs to explain public methods. Not sure about how do I set a start/end position? How do I animate the spring etc.. some really simple examples would be great!
👍
The text was updated successfully, but these errors were encountered: