|
| 1 | +<html> |
| 2 | + <head> |
| 3 | + <style> |
| 4 | + body { |
| 5 | + margin: 0; |
| 6 | + font-family: sans-serif; |
| 7 | + } |
| 8 | + |
| 9 | + .container { |
| 10 | + display: flex; |
| 11 | + gap: 10px; |
| 12 | + flex-direction: column; |
| 13 | + height: 200vh; |
| 14 | + } |
| 15 | + |
| 16 | + .box { |
| 17 | + width: 100px; |
| 18 | + height: 100px; |
| 19 | + background-color: #0077ff; |
| 20 | + display: flex; |
| 21 | + align-items: center; |
| 22 | + justify-content: center; |
| 23 | + text-align: center; |
| 24 | + position: fixed; |
| 25 | + } |
| 26 | + </style> |
| 27 | + </head> |
| 28 | + <body> |
| 29 | + <div class="container"> |
| 30 | + <div class="box" id="mini" style="top: 0px">mini</div> |
| 31 | + <div class="box" id="js" style="top: 100px">js</div> |
| 32 | + <div class="box" id="waapi" style="top: 200px">waapi</div> |
| 33 | + </div> |
| 34 | + <script type="module" src="/src/inc.js"></script> |
| 35 | + <script type="module"> |
| 36 | + const { animateMini, animate, scroll, delay } = window.Motion |
| 37 | + |
| 38 | + const options = { |
| 39 | + duration: 0.2, |
| 40 | + } |
| 41 | + |
| 42 | + const miniElement = document.querySelector("#mini") |
| 43 | + const jsElement = document.querySelector("#js") |
| 44 | + const waapiElement = document.querySelector("#waapi") |
| 45 | + |
| 46 | + const mini = animateMini( |
| 47 | + miniElement, |
| 48 | + { transform: "translateX(100px)" }, |
| 49 | + options |
| 50 | + ) |
| 51 | + const js = animate(jsElement, { x: 100 }, options) |
| 52 | + const waapi = animate( |
| 53 | + waapiElement, |
| 54 | + { transform: "translateX(100px)" }, |
| 55 | + options |
| 56 | + ) |
| 57 | + |
| 58 | + const scrollOptions = { |
| 59 | + offset: ["start start", "end end"], |
| 60 | + } |
| 61 | + |
| 62 | + scroll(mini, scrollOptions) |
| 63 | + scroll(js, scrollOptions) |
| 64 | + scroll(waapi, scrollOptions) |
| 65 | + </script> |
| 66 | + </body> |
| 67 | +</html> |
0 commit comments