Last active
August 29, 2015 14:13
-
-
Save alepee/e6ba2a64bf173e6863cb to your computer and use it in GitHub Desktop.
Edge Animate CC responsive layout based on parent element width
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
// 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