Created
June 17, 2013 20:02
-
-
Save sorvell/5799839 to your computer and use it in GitHub Desktop.
ShadowDOM polyfill and css transition
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
<html> | |
<head> | |
<script src="../../../ShadowDOM/shadowdom.js"></script> | |
<style> | |
.transformy { | |
-webkit-transition: -webkit-transform 1s; | |
background: beige; | |
} | |
.flipped { | |
-webkit-transform: rotateY( 180deg ); | |
} | |
</style> | |
</head> | |
<body> | |
<div id="host"> | |
<div id="target" class="transformy">Hello World</div> | |
</div> | |
<button onclick="flip()">Flip</button> | |
<script> | |
// make a shadowRoot that distributes | |
var host = document.querySelector('#host'); | |
var root = host.createShadowRoot(); | |
root.innerHTML = '<content></content>'; | |
// | |
// toggle flipped class | |
var target = document.querySelector('#target'); | |
function flip() { | |
target.setAttribute('class', 'transformy' + | |
(target.classList.contains('flipped') ? '' : ' flipped')); | |
// | |
// works, but does not trigger ShadowDOM distribution | |
//target.classList.toggle('flipped'); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment