Created
April 12, 2018 21:31
-
-
Save nicksteffens/9227d30e754b34889bed40a47be6e8a2 to your computer and use it in GitHub Desktop.
Masonry Attempt via CSS & Sort Order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { computed } = Ember; | |
export default Ember.Component.extend({ | |
tagName: 'ul', | |
classNames: ['image-gallery'], | |
classNameBindings: ['modifier'], | |
modifier: null, | |
sortedImages: computed('images', 'modifier', function() { | |
if ( this.get('modifier') !== 'masonry') { | |
return this.get('images') | |
} else { | |
return this._sortImages(this.get('images')); | |
} | |
}), | |
_sortImages(images) { | |
const column1 = images.filter(function(value, index) { | |
return index % 3 === 0; | |
}); | |
const column2 = images.filter(function(value, index) { | |
return index % 3 === 1; | |
}); | |
const column3 = images.filter(function(value, index) { | |
return index % 3 === 2; | |
}); | |
const sortedImages = column1.concat(column2).concat(column3); | |
return sortedImages; | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
images: [ | |
'https://placem.at/people?w=150&h=150&txt=1', | |
'https://placem.at/people?w=150&h=250&txt=2', | |
'https://placem.at/people?w=150&h=100&txt=3', | |
'https://placem.at/people?w=150&h=110&txt=4', | |
'https://placem.at/people?w=150&h=180&txt=5', | |
'https://placem.at/people?w=150&h=150&txt=6', | |
'https://placem.at/people?w=150&h=120&txt=7', | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.image-gallery { | |
list-style-type: none; | |
} | |
.image-gallery.column, | |
.image-gallery.masonry { | |
column-count: 3; | |
column-gap: 5px; | |
} | |
.image-gallery.grid { | |
display: grid; | |
grid-template-columns: 1fr 1fr 1fr; | |
grid-column-gap: 5px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.13.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.16.2", | |
"ember-template-compiler": "2.16.2", | |
"ember-testing": "2.16.2" | |
}, | |
"addons": { | |
"ember-data": "2.16.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment