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

Views added to context after context has been mounted need a resize event to be render #63

Open
frh3ddy opened this issue Mar 14, 2017 · 2 comments

Comments

@frh3ddy
Copy link

frh3ddy commented Mar 14, 2017

I don't think is a bug, but I guess it will be useful to be able to add views to context after it has been mounted, I understand that Views have a low-footprint, but if the view is composes of many other views it could take a little linger to calculate layout and size. I wanna be able to render the view only after an action has happen.

If I dispatch a resize event on window, it should work but since the size is the same the engine never emits a resize event,
#L153-L154

@frh3ddy frh3ddy changed the title Views added to context after context has been mounted need a resize event to be rende Views added to context after context has been mounted need a resize event to be render Mar 14, 2017
@dmvaldman
Copy link
Owner

Hmm, this is supposed to work as you suggest. Do you have a small demo example?

Specifically, this ugly code, is supposed to refire the resize event (and other events)

@frh3ddy
Copy link
Author

frh3ddy commented Mar 15, 2017

I created a codepen, here

A gridView should be added when clicking on add view button, but the View doesn't show up until a window resize event happen,

But thanks to you know I know why it doesn't work.
its because if the condition on line#100 is met, it returns, and it will exit before getting to this code

so instead of just returning the new node.

// View case
const addedView = node._onAdd(this);
var self = this;
preTickQueue.push(function(){
	if (!self._cachedSpec.size) return;
	self.size.trigger('start', self._cachedSpec.size);
	self.layout.trigger('start', self._cachedSpec.layout);
	dirtyQueue.push(function(){
		self.size.trigger('end', self._cachedSpec.size);
		self.layout.trigger('end', self._cachedSpec.layout);
	});
});

return addedView

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

No branches or pull requests

2 participants