|
| 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