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

Clarify transitions API & lifecycle callbacks. #8

Open
aaronc opened this issue Nov 18, 2014 · 6 comments
Open

Clarify transitions API & lifecycle callbacks. #8

aaronc opened this issue Nov 18, 2014 · 6 comments

Comments

@aaronc
Copy link
Owner

aaronc commented Nov 18, 2014

No description provided.

@aaronc aaronc self-assigned this Nov 18, 2014
@martinklepsch
Copy link

👍

@aaronc aaronc changed the title Clarify transitions API Clarify transitions API - what lifecycle callbacks are needed? Nov 26, 2014
@aaronc aaronc changed the title Clarify transitions API - what lifecycle callbacks are needed? Clarify transitions API & lifecycle callbacks. Nov 26, 2014
@aaronc
Copy link
Owner Author

aaronc commented Nov 26, 2014

Currently I've added support for data-state based transitions. If data-state is bound to some atom, rx, etc., if its value changes to new-state for instance, and :on-new-state transition callback (currently passed as metadata to the "hiccup" vector) will be fired if present.

Comments on this as well as what lifecycle callbacks should/shouldn't be present welcome.

@BorisKourt
Copy link

Just saw this pop up in the CLJS group: https://github.com/pleasetrythisathome/bardo
Here is the group post: https://groups.google.com/forum/#!topic/clojurescript/JROUw58NPX0
And here is a possibly relevant example with OM: https://github.com/pleasetrythisathome/bardo/blob/master/examples/om.cljs

Maybe some ideas align enough for this to be delegated to an external library? I know that doesn't feel like it melds with your design goals, but still just throwing this out there.

@aaronc
Copy link
Owner Author

aaronc commented Dec 14, 2014

Yeah, well actually I was hoping that the easing functions could be delegated to an external library. This looks pretty good. I may suggest people use it in the README - the idea with freactive animations is to let people use whatever easing functions they like and ideally I'd prefer not to maintain that library...

@aaronc
Copy link
Owner Author

aaronc commented Dec 14, 2014

See #7

@aaronc
Copy link
Owner Author

aaronc commented Jan 2, 2015

FYI in 0.2.0-SNAPSHOT all node life-cycle callbacks have been moved to the attribute map itself (where other DOM attrs are stored). Currently supported life-cycle callbacks are :node/on-attached which takes a single arg for the node and is suitable for animation, :node/on-detaching which takes the DOM node and a callback which must be called after any animation is complete and only called at binding/removal sites, and :node/on-disposed which takes no args currently.

Also planned are :node/on-moving, :node/on-moved and possibly a :node/on-created. I may add a single parameter to :node/on-created and :node/on-detaching which is a unique ID for the node (the node itself isn't sufficient because they get reused) - this is in case anyone really needs to do some complex resource mangement coordinated with node creation/disposal.

data-state transitions are now supported via the attribute map as :state/on-new-state callbacks. Callbacks receive 3 args: the node, the old state and the new state.

Binding-level life-cycle callbacks are attached as metadata to ref types (i.e. rx, atom, cursor etc.) via alter-meta!. Currently supported are for node bindings only now are :binding-initialized and :binding-disposed which take no args as well as :binding-invalidated which takes the currently bound node and the ref as args. :binding-invalidated also allows a :cancel return argument to cancel the current re-render - maybe this binding and its behavior should be thought out more thoroughly. Any input? For attribute bindings only :binding-disposed is currently supported but I intend to implement at least :binding-initialized.

Any input is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants