Skip to content

Instantly share code, notes, and snippets.

@alepee
Last active August 29, 2015 14:13
Show Gist options
  • Save alepee/e6ba2a64bf173e6863cb to your computer and use it in GitHub Desktop.
Save alepee/e6ba2a64bf173e6863cb to your computer and use it in GitHub Desktop.
Edge Animate CC responsive layout based on parent element width
// Copy/Paste this script into your main Stage within `compositionReady`
(function(){
var stage = sym.getSymbolElement('.' + e.compId);
var parent = stage.parent();
var stageWidth = stage.width();
var stageHeight = stage.height();
stage.css({
transformOrigin: '0 0'
})
function scaleStage() {
var parentWidth = parent.width();
stage.css({
transform: 'scale('+ parentWidth / stageWidth +')'
})
}
window.addEventListener('resize', function(){
if (window.requestAnimationFrame) {
window.requestAnimationFrame(scaleStage);
}
else {
scaleStage();
}
});
scaleStage();
}).call(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment