|
| 1 | +<html> |
| 2 | + <head> |
| 3 | + <style> |
| 4 | + body { |
| 5 | + padding: 0; |
| 6 | + margin: 0; |
| 7 | + } |
| 8 | + |
| 9 | + #container { |
| 10 | + width: 100px; |
| 11 | + height: 200px; |
| 12 | + display: flex; |
| 13 | + align-items: flex-end; |
| 14 | + transform-style: preserve-3d; |
| 15 | + background-color: blue; |
| 16 | + } |
| 17 | + |
| 18 | + #container.b { |
| 19 | + align-items: flex-start; |
| 20 | + } |
| 21 | + |
| 22 | + #box { |
| 23 | + width: 100px; |
| 24 | + height: 100px; |
| 25 | + background-color: #00cc88; |
| 26 | + padding: 10px; |
| 27 | + display: flex; |
| 28 | + align-items: flex-start; |
| 29 | + } |
| 30 | + |
| 31 | + .b #box { |
| 32 | + align-items: flex-end; |
| 33 | + } |
| 34 | + |
| 35 | + #box-child { |
| 36 | + width: 50px; |
| 37 | + height: 50px; |
| 38 | + background-color: #cc00cc; |
| 39 | + } |
| 40 | + |
| 41 | + #trigger-overflow { |
| 42 | + width: 1px; |
| 43 | + height: 1px; |
| 44 | + position: absolute; |
| 45 | + top: 2000px; |
| 46 | + left: 2000px; |
| 47 | + } |
| 48 | + |
| 49 | + [data-layout-correct="false"] { |
| 50 | + background: #dd1144 !important; |
| 51 | + opacity: 0.5; |
| 52 | + } |
| 53 | + </style> |
| 54 | + </head> |
| 55 | + |
| 56 | + <body> |
| 57 | + <div id="container"> |
| 58 | + <div id="box" data-layout-correct="true"> |
| 59 | + <div id="box-child"></div> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + <div id="trigger-overflow"></div> |
| 63 | + |
| 64 | + <script src="../../packages/framer-motion/dist/projection.dev.js"></script> |
| 65 | + <script src="./script-assert.js"></script> |
| 66 | + <script src="./script-undo.js"></script> |
| 67 | + <script> |
| 68 | + const { createNode } = window.Undo |
| 69 | + const { matchViewportBox, matchSkewX } = window.Assert |
| 70 | + const container = document.getElementById("container") |
| 71 | + const containerProjection = createNode(container, undefined, { |
| 72 | + layout: false, |
| 73 | + }) |
| 74 | + const box = document.getElementById("box") |
| 75 | + const boxProjection = createNode(box, containerProjection) |
| 76 | + const boxChild = document.getElementById("box-child") |
| 77 | + const boxChildProjection = createNode(boxChild, boxProjection) |
| 78 | + |
| 79 | + containerProjection.setValue("rotateX", 40) |
| 80 | + containerProjection.setValue("transformPerspective", 500) |
| 81 | + boxProjection.setValue("rotateX", 10) |
| 82 | + boxProjection.setValue("z", 20) |
| 83 | + |
| 84 | + requestAnimationFrame(() => { |
| 85 | + const boxOrigin = box.getBoundingClientRect() |
| 86 | + boxProjection.willUpdate() |
| 87 | + boxChildProjection.willUpdate() |
| 88 | + containerProjection.willUpdate() |
| 89 | + container.classList.add("b") |
| 90 | + |
| 91 | + requestAnimationFrame(() => { |
| 92 | + containerProjection.root.didUpdate() |
| 93 | + frame.postRender(() => { |
| 94 | + matchViewportBox(box, boxOrigin) |
| 95 | + }) |
| 96 | + }) |
| 97 | + }) |
| 98 | + </script> |
| 99 | + </body> |
| 100 | +</html> |
0 commit comments