Simplify the modal dialog example using Tossable and TransitionSpring.

Authored by featherless on Mar 7 2017, 3:41 PM.



The previous implementation was essentially rewriting Tossable. This change refactors the interaction to make use of the Tossable interaction by providing a TransitionSpring to Tossable. This takes advantage of the fact that TransitionSpring is a subclass of Spring and that Tossable can be provided with an existing Spring instance.

Note that this diff makes it possible to drag the modal dialog on the x-axis. In a follow-up diff I will introduce constraints so that this interaction can be locked to the y axis.

Diff Detail

rREACTIVEMOTIONSWIFT reactive-motion-swift
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
featherless created this revision.Mar 7 2017, 3:41 PM
markwei accepted this revision.Mar 7 2017, 6:32 PM
markwei added a subscriber: markwei.
markwei added inline comments.

it's not obvious why spring is passed back here, and not tossable/draggable. This API allows the user to make the simple mistake of returning the tossable instead.

This revision is now accepted and ready to land.Mar 7 2017, 6:32 PM
featherless added inline comments.Mar 7 2017, 7:52 PM

Tossable isn't a StatefulInteraction type, so it can't be returned.

That being said, I do think that tossable should be returnable here, but it requires that Tossable aggregate its sub-interaction states into a single state. At this point this is a pretty clear pattern, so I'll probably explore providing some sort of API for providing aggregate state again in the context of Interactions.

featherless edited the summary of this revision. (Show Details)Mar 7 2017, 7:53 PM
This revision was automatically updated to reflect the committed changes.