Last active
January 13, 2018 01:35
-
-
Save scudco/46a2bc768c36b17cef752b0e92d01fc4 to your computer and use it in GitHub Desktop.
Holy Grail Scalable Container
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.Component.extend({ | |
}); |
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.Component.extend({ | |
}); |
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'; | |
import { requestAnimationFrame } from '../util/raf' | |
export default Ember.Component.extend({ | |
_scale: 1, | |
classNames: ['scalable-container'], | |
didInsertElement() { | |
requestAnimationFrame(() => this.updateScale()); | |
}, | |
updateScale() { | |
if (this.isDestroyed) { return; } | |
let grandParentWidth = this.$().parent().parent().parent().width(); | |
let scale = this.$().parent().width() / grandParentWidth; | |
console.log(grandParentWidth, scale); | |
// If the scale has significantly changed | |
if (Math.abs(this._scale - scale) > 0.0001) { | |
this.$().css({ | |
transform: `scale(${scale})`, | |
width: `${grandParentWidth}px`, | |
}); | |
this._scale = scale; | |
} | |
//requestAnimationFrame(() => this.updateScale()); | |
} | |
}); |
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' | |
}); |
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
* { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
} | |
body { | |
margin: 0; | |
position: absolute; | |
height: 100%; | |
width: 100%; | |
display: flex; | |
flex-direction: column; | |
} | |
.holy-grail { | |
display: flex; | |
flex: 1; | |
} | |
header { | |
background: #AAA; | |
} | |
nav { | |
background: #DDD; | |
flex: 0 0 120px; | |
order: -1; | |
} | |
main { | |
flex: 1; | |
border: 1px solid red; | |
overflow: scroll; | |
} | |
aside { | |
background: #DDD; | |
flex: 0 0 120px; | |
} | |
footer { | |
background: #AAA; | |
} | |
.scalable-container { | |
transform-origin: 0 0; | |
will-change: transform; | |
} | |
main p { | |
margin-bottom: 1rem; | |
} |
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.0", | |
"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" | |
} | |
} |
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
export function requestAnimationFrame(callback) { | |
if (window.requestAnimationFrame) { | |
return window.requestAnimationFrame(callback); | |
} | |
return setTimeout(callback, 2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment