Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Add eventing system to meta to determine when nodes are processed #662

Closed
tomdye opened this issue Sep 6, 2017 · 0 comments · Fixed by #666
Closed

Add eventing system to meta to determine when nodes are processed #662

tomdye opened this issue Sep 6, 2017 · 0 comments · Fixed by #666
Assignees
Milestone

Comments

@tomdye
Copy link
Member

tomdye commented Sep 6, 2017

Enhancement

In some circumstances, animations being one of them, we need to delay the requiring of a node until we can be sure that all node properties have been processed and all HTMLElements are correctly laid out. This is especially important in Animations as we need to get access to a nodes dimensions in a lot of cases which may be dependent on the styles applied to parent elements. With the current implementation, the requireNode callback triggers before parents are processed.

We should consider implementing an event based system similar to the way that used in RegistryHandler. The implementation could allow users to register for an event when a given node, or level of nodes has been processed and made available.

For example:

// fires when node with `myKey` is available
nodeHandler.on({ type: 'node', key: 'myKey' }, callback); 

// fires when the widget root is available
nodeHandler.on({ type: 'widget' }, callback); 

// fires when the projector is available
nodeHandler.on({ type: 'projector' }, callback); 

The benefit of this approach is that in the case of animations, you can wait for the projector to be processed before adding any animations. This ensures that all HTMLElements have been laid out and had styles applied.

nodeHandler.on({ type: 'projector' }, () => {
   const myAnimatedNode = this.nodes('myKey');
  // calculate and add animation here
});
@tomdye tomdye changed the title Required Node callbacks fire before all widget node properties are processed Add eventing system to meta to determine when nodes are processed Sep 6, 2017
@tomdye tomdye self-assigned this Sep 6, 2017
@dylans dylans added this to the 2017.09 milestone Sep 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants