Last active
July 18, 2016 11:11
-
-
Save timmyomahony/aac5537cb1b6cb8263512b682b049467 to your computer and use it in GitHub Desktop.
Telling your parents you've rendered
This file contains 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.Component.extend({ | |
tagName: 'li', | |
classNames: ['slide-list__list__item'], | |
didInsertElement() { | |
this._super(...arguments); | |
this.get('childRendered')(); | |
} | |
}); |
This file contains 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.Component.extend({ | |
childCount: 0, | |
items: [], | |
tagName: 'div', | |
classNames: ['slide-list'], | |
initialCount: 5, | |
resizeList() { | |
var self = this, | |
ul = self.$('.slide-list__list'), | |
li = self.$('.slide-list__list__item'), | |
w = Math.ceil(self.$().outerWidth()), | |
li_w = Math.ceil(w/self.get('initialCount')), | |
ul_w = Math.ceil($(li).length * li_w); | |
$(li).outerWidth(li_w); | |
$(ul).outerWidth(ul_w); | |
}, | |
didInsertElement() { | |
this._super(...arguments); | |
this.$(window).on('resize', this.resizeList); | |
}, | |
actions: { | |
childRendered() { | |
var self = this; | |
self.set('childCount', self.get('childCount') + 1); | |
if(self.get('childCount') === self.get('items.length')) { | |
self.resizeList(); | |
} | |
} | |
} | |
}); |
This file contains 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({ | |
items: Ember.computed(function(){ | |
var a = []; | |
var s = 21; | |
while(s--) a.push({text: s}); | |
return a; | |
}) | |
}); |
This file contains 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
* { | |
box-sizing: border-box; | |
} | |
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.container { | |
background-color: black; | |
width: 100%; | |
} | |
.slide-list{ | |
} | |
.slide-list__window { | |
margin: 0; | |
padding: 0; | |
overflow-x: scroll; | |
overflow-y: hidden; | |
width: 100%; | |
} | |
.slide-list__list { | |
margin: 0; | |
padding: 0; | |
width: 10000px; | |
} | |
.slide-list__list:after { | |
content: ""; | |
display: table; | |
clear: both; | |
} | |
.slide-list__list__item { | |
border: 1px solid grey; | |
color: white; | |
float: left; | |
list-style: none; | |
padding: 2rem 0; | |
margin: 0; | |
text-align: center; | |
} |
This file contains 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.10.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.6.0", | |
"ember-data": "2.6.1", | |
"ember-template-compiler": "2.6.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment