gsap实现鼠标滚动横向相册效果代码
代码语言:html
所属分类:画廊相册
代码描述:gsap实现鼠标滚动横向相册效果代码,结合了ScrollSmoother、ScrollTrigger、gsap、SplitText3
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.5.0.css"> <style> @import url("https://fonts.googleapis.com/css2?family=Signika+Negative:wght@400;600&display=swap"); header, footer, #smooth-content { visibility: hidden; } html, body { padding: 0; margin: 0; } body { position: relative; overflow-x: hidden; background-color: #161616; font-family: "Signika Negative", sans-serif; color: white; } header { box-sizing: border-box; position: fixed; display: flex; align-items: center; justify-content: space-between; padding: 0 5%; width: 100%; z-index: 3; height: 7em; font-size: clamp(0.66rem, 2vw, 1rem); letter-spacing: 0.2em; } .heading { position: fixed; margin: 0; top: 50%; transform: translateY(-50%); width: 100%; text-align: center; font-weight: 600; opacity: 0; } .heading h1 { font-size: 12vw; } #container { display: flex; flex-wrap: wrap; flex-direction: column; height: 100vh; will-change: transform; } .section { position: relative; width: 50vw; height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; transform: perspective(400px); transform-style: preserve-3d; max-width: 500px; } .hide { overflow: hidden; margin-top: 1.2rem; } h1, h2 { margin: 0; } h1 > *, h2 > * { will-change: transform; } h2 { font-size: clamp(0.66rem, 3vw, 2.5rem); margin: 0; } p { margin-top: 0.5rem; opacity: 0.4; } .section--lg, .end { min-width: 100vw; } .card { width: 80%; z-index: 999; } .card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; } .section:nth-child(2n) { margin-top: -10vh; } .section:nth-child(3n) { margin-top: 30vh; } .noise { position: fixed; top: 0; width: 100%; height: 100%; opacity: 0.2; } img { border-radius: 10px; } footer { position: fixed; bottom: 1rem; text-align: center; width: 100%; font-size: clamp(0.66rem, 2vw, 1rem); letter-spacing: 0.2em; font-weight: 100; } .green { position: fixed; width: 100vw; height: 100vh; top: 0; left: 0; background-color: #28a92b; z-index: 999; opacity: 0; will-change: transform; } .end { margin: 0!important; } .end h2 { font-size: 5vw; } </style> </head> <body > <header> <div>GSAP</div> <div>showcase</div> </header> <div class="hide heading"> <h1>CODEPENS 2022</h1> </div> <div id="smooth-content"> <section id="container"> <div class="section section--lg"> </div> </section> </div> <footer> <p>scroll to see our picks...</p> </footer> <div class="green"></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/SplitText3.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.8.0.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ScrollTrigger.3.10.4.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ScrollSmoother.min.js"></script> <script > gsap.registerPlugin(ScrollTrigger, ScrollSmoother, SplitText); const cont = document.querySelector("#container"); const pens = [ { title: "Ribbon Stack", author: "Chris Gannon", url: "https://codepen.io/chrisgannon/pen/MWGRVrx" }, { title: "GSAP Plains", author: "Brent Morton", url: "https://codepen.io/b1mind/pen/QWmLXmO" }, { title: "Parametric spider", author: "Fabio Ottaviani", url: "https://codepen.io/supah/pen/vYdwbQK" }, { title: "Alphabet Soup", author: "Ryan Mulligan", url: "https://codepen.io/hexagoncircle/pen/ExoKBgW" }, { title: "Bubblegum", author: "Natalia 🤟", url: "https://codepen.io/natszafraniec/pen/oNGmoOa" }, { title: "Chess Movement", author: "Peter Norton", url: "https://codepen.io/graphilla/pen/QWmNyXv" }, { title: "Hack", author: "Jamie Coulter", url: "https://codepen.io/jcoulterdesign/pen/abYNyLq" }, { title: "A little to the right", author: "Alex Trost", url: "https://codepen.io/a-trost/pen/jOZXdoP" }, { title: "ScrollSmoother", author: "Malven", url: "https://codepen.io/cmalven/pen/PoEJvjE" }, { title: "Chroma Cycle", author: "Chris Gannon", url: "https://codepen.io/chrisgannon/pen/vYaGJgM" }, { title: "CSSkateboard", author: "Ryan Mulligan", url: "https://codepen.io/hexagoncircle/pen/GRBJLwE" }, { title: "Isopleths", author: "Louis Hoebregts", url: "https://codepen.io/Mamboleoo/pen/KKZRvEp" }, { title: "Invert Text", author: "Craig Roblewsky", url: "https://codepen.io/PointC/pen/ZErvbPR" }, { title: "Spider UI", author: "Elegant Seagulls", url: "https://codepen.io/elegantseagulls/pen/WNyNXMQ" }, { title: "Stop Motion", author: "h1", url: "https://codepen.io/huxhu/pen/JjGNeOy" }, { title: "Generative Plants", author: "Louis Hoebregts", url: "https://codepen.io/Mamboleoo/pen/mdqybaG" }, { title: "MetroGnome", author: "Ryan Mulligan", url: "https://codepen.io/hexagoncircle/pen/JjOaabp" }, { title: "Scrolling Rainbow", author: "Fabio Ottaviani", url: "https://codepen.io/supah/p.........完整代码请登录后点击上方下载按钮下载查看
网友评论0