Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 9c4c34a

Browse files
committed
Merge pull request #20 from shans/shadow
Add support for shadow DOM.
2 parents 25d0a2f + a53fa20 commit 9c4c34a

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

layoutAnimationShim/src/layout-animation.js

+7
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,13 @@ function cloneElementToSize(node, rect) {
938938
div.style.height = rect.height + 'px';
939939
div.innerHTML = node.innerHTML;
940940

941+
if (node.shadowRoot) {
942+
var root = div.createShadowRoot();
943+
for (var i = 0; i < node.shadowRoot.childNodes.length; i++) {
944+
root.appendChild(node.shadowRoot.childNodes[i].cloneNode(true));
945+
}
946+
}
947+
941948
var transitionChildren = node.querySelectorAll("[isTransitionable]");
942949
var transitionMirrors = div.querySelectorAll("[isTransitionable]");
943950
for (var i = 0; i < transitionChildren.length; i++) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<script src="../../../web-animations-js/web-animations.js"></script>
5+
<script src="../../layoutAnimationShim/src/layout-animation.js"></script>
6+
<style>
7+
body {
8+
margin: 0;
9+
padding: 0;
10+
background-color: black;
11+
text-align: center;
12+
}
13+
.item {
14+
width: 400px;
15+
margin: 0 auto;
16+
background-color: white;
17+
border-bottom: 1px solid dimgrey;
18+
padding: 10px;
19+
}
20+
</style>
21+
</head>
22+
<body>
23+
<div id="container">
24+
<div class="item">light</div>
25+
<div class="item">light</div>
26+
<div class="item">light</div>
27+
<div class="item">light</div>
28+
<div class="item">light</div>
29+
</div>
30+
<script>
31+
document.addEventListener('DOMContentLoaded', function() {
32+
registerLayoutKeyframes('default', [
33+
{offset: 0, properties: {
34+
layoutWidth: 'from()', layoutHeight: 'from()', layoutTop: 'from()', layoutLeft: 'from()'
35+
}},
36+
{offset: 1, properties: {
37+
layoutWidth: 'to()', layoutHeight: 'to()', layoutTop: 'to()', layoutLeft: 'to()'
38+
}}
39+
]);
40+
41+
var hangouts = document.querySelectorAll('.item');
42+
var template = document.querySelector('#tmpl');
43+
for (var i = 0, h; h = hangouts[i]; i++) {
44+
var root = h.createShadowRoot();
45+
root.appendChild(document.createTextNode('shadow'));
46+
}
47+
setLayoutTransition(hangouts, 'default', 1);
48+
setLayoutEffect(hangouts, 'layout');
49+
50+
var container = document.querySelector('#container');
51+
container.addEventListener('click', function(e) {
52+
transitionThis(function() {
53+
container.insertBefore(e.target, container.children[0]);
54+
}.bind(this));
55+
})
56+
});
57+
</script>
58+
</body>
59+
</html>

0 commit comments

Comments
 (0)