eviltrout / ember-cloaking

Support for not rendering offscreen views in an Ember app for performance
MIT License
294 stars 29 forks source link

Stop rendering ALL cloaked views #9

Closed H1D closed 9 years ago

H1D commented 10 years ago

It turned out that ember-cloakning uncloaks all views first and only then cloaks it back :expressionless:

Demo http://jsbin.com/ACikukuCA/35/edit (check out console)

Is it by design?

We can change this line to this.cloak() but it's half-measure. Some kind of progressive rendering should be implemented which would check what's on screen after each view uncloaked.

H1D commented 10 years ago

Changing line has no effect because defaultHeight is not really used now and all cloak-views have 0 height so ember-cloaks uncloaks all of them since they are all on screen =))

eviltrout commented 10 years ago

I found it was best to render them all up to get initial heights and then cloak, but that might just be better for our use case. I would love to fix this to help you out if I can. What would you suggest?

H1D commented 10 years ago

@eviltrout I did 3 things in my fork:

  1. utilazing defaultHeight
  2. implemented defaultCloakHeight support (method on a model that predicts height of a view)
  3. always render only visible views (+ slack of course)

You might find that 2. is kind of "tricky hacky" but cmon'! ember-cloaking is a kind of hack by itself =)

BTW 2. can be improved greatly: after first view rendered we can calculate "correction coefficient" based on predicted and real height and then use it for all other views.

So what do you think?

H1D commented 10 years ago

@eviltrout ping

eviltrout commented 10 years ago

Sorry it's been a long week! I will look at this soon.

On Thursday, February 27, 2014, Artem Suschev notifications@github.com wrote:

@eviltrout https://github.com/eviltrout ping

Reply to this email directly or view it on GitHubhttps://github.com/eviltrout/ember-cloaking/issues/9#issuecomment-36236225 .

H1D commented 10 years ago

OK, understood

eviltrout commented 10 years ago

Sure, those seem reasonable. Send over a PR and I'll merge it :)

runspired commented 9 years ago

@eviltrout I believe we can close this: https://github.com/eviltrout/ember-cloaking/pull/15