Skip to content

Instantly share code, notes, and snippets.

@ninegrid
Created February 3, 2014 22:31
Show Gist options
  • Save ninegrid/8793814 to your computer and use it in GitHub Desktop.
Save ninegrid/8793814 to your computer and use it in GitHub Desktop.
an ember view for masonry
{{#view "masonic"}}
<section class="bricks">
{{! your template here}}
</section>
{{/view}}
var MasonicView = Ember.View.extend({
didInsertElement: function() {
this.scheduleMasonry();
},
scheduleMasonry: (function() {
Ember.run.scheduleOnce('afterRender', this, this.applyMasonry);
}),
applyMasonry: function() {
setTimeout(function() {
this.$('.bricks').masonry({
itemSelector: '.brick',
columnWidth: 0,
gutter: 0
});
},100);
},
contentDidChange: function() {
if(this.get("state") === "inDOM") {
this.applyMasonry();
}
}
});
export default MasonicView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment