1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| <!DOCTYPE html> <html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>GSAP</title> </head>
<body style="overflow-x: hidden;"> <div class="ani-container"> <div class="box"> <svg id="layer-1" class="mysvg" xmlns="http://www.w3.org/2000/svg" > <path class="line" d="M779.4,65.5c-194-9-503,52-503,83s387-53,387-10s-523,31-523,101c0,53,784-128,784-54 c0,59-937.4,72.7-937.4,141.3c0,45.7,1011.4-124.3,1011.4-75.3s-1029,83-1029,140s1159-162.7,1078-83c-66,65-1100,90-1091,139 c8.7,47.5,1091-121,1091-53s-1068,21-1068,110c0,57,919-27,1074-33" fill="none" stroke-width="300"></path> </svg> <div class="bg"> <img style="object-fit: cover;" width="100%" height="100%" src="./img.jpeg" alt="" srcset=""> </div> </div> </div> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/gsap/3.9.1/gsap.min.js" type="application/javascript"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/gsap/3.9.1/ScrollTrigger.min.js" type="application/javascript"></script> <script> gsap.registerPlugin(ScrollTrigger) let tl = gsap.timeline() gsap.fromTo(".line", { strokeDashoffset: ()=>{ return document.querySelector('.line').getTotalLength() + 1 }, strokeDasharray: ()=>{ return document.querySelector('.line').getTotalLength() + 1 }, }, { strokeDashoffset: 0, strokeDasharray: ()=>{ return document.querySelector('.line').getTotalLength() + 1 }, duration: 2, ease: "none", opacity: 1, scrollTrigger: { trigger: '.box', scrub: 0, markers: true, start: "top 60%", end: "bottom 40%", toggleActions: "restart none none none", onLeave: () => { }, onEnterBack: () => { } } }); </script> <style> body { display: flex; align-items: center; justify-content: space-around; height: 300vh; margin: 0; } .ani-container { width: 600px; height: 600px; border: 1px solid black; display: flex; align-items: center; justify-content: center; }
.box { width: 600px; height: 600px; position: relative;
} .bg{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2; } .mysvg{ width: 100%; height: 100%; z-index: 3; position: absolute; background-color: #FFF; mix-blend-mode: lighten; } .line{ stroke: #000; stroke-width: 80; stroke-linecap: round; left: -50%; } </style> </body>
</html>
|