Support for not rendering offscreen views in an Ember app for performance and lowered memory usage.
Extracted from Discourse's infinite scrolling.
- Include
ember-cloaking.js
in your project. - To display a collection of cloaked items, use
{{cloaked-collection}}
in your handlebars templates like this:
cloakView
is the name of the view to render in the collection. post
would render PostView
.
itemController
is the name of the controller for items in collection; if not set will be resolved using cloakView
name
defaultHeight
is the height of the cloaked views by default. You should pick a value that is in the ballpark of
your average view height. Note: Your views don't have to be the same height.
content
is the collection of items to display.
loadingHTML
is the HTML you want to render while the cloaking is loading. If omitted it will default to "Loading..."
wrapperTop
is the current scroll position like native element.scrollTop
wrapperHeight
is the height of the "window" in which content scrolling
MIT