gsap实现滚动图片三维翻转幻灯片动画效果代码

代码语言:html

所属分类:幻灯片

代码描述:gsap实现滚动图片三维翻转幻灯片动画效果代码

代码标签: 图片 三维 翻转 幻灯片 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
<style>
*,
*:after,
*:before {
  box-sizing: border-box;
}
body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow-y: hidden;
  background: var(--bg);
}
.drag-proxy {
  visibility: hidden;
  position: absolute;
}
ul {
  height: 100vh;
  width: 100%;
  overflow: hidden;
  position: absolute;
  transform-style: preserve-3d;
  perspective: 800px;
  touch-action: none;
  padding: 0;
  margin: 0;
}
li {
  position: absolute;
  transform-style: preserve-3d;
  top: 50%;
  left: 50%;
  height: 15vmin;
  width: 15vmin;
  min-height: 150px;
  min-width: 150px;
  display: none;
  background: #b3f075;
}
img {
  position: absolute;
  height: 100%;
  width: 100%;
  -o-object-fit: cover;
     object-fit: cover;
}
</style>



</head>

<body  >
  <ul>
  <li class="a"><img src="//repo.bfw.wiki/bfwrepo/image/5d653b1fc8bc9.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="cut citrus fruits."/><span>Lorem Ipsum</span></li>
  <li class="b"><img src="//repo.bfw.wiki/bfwrepo/image/5d653ba895333.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="sliced mango."/><span>Dolor Sit</span></li>
  <li class="c"><img src="//repo.bfw.wiki/bfwrepo/image/5d653be845a41.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="a bunch of blueberries."/><span>Amet Consectetur</span></li>
  <li class="d"><img src="//repo.bfw.wiki/bfwrepo/image/5e0c6f2cae508.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="a pineapple sitting on a table."/><span>Adipiscing Elit</span></li>
  <li class="e"><img src="//repo.bfw.wiki/bfwrepo/image/5fbedf8f5349c.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="frozen raspberries."/><span> Nunc Tortor</span></li>
  <li class="f"><img src="//repo.bfw.wiki/bfwrepo/image/5fc1b6b06272d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="a sliced strawberry."/><span>Metus Mollis</span></li>
  <li class="g"><img src="//repo.bfw.wiki/bfwrepo/image/5fe1bc8e0ed82.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="an arrangement of assorted sliced fruits."/><span>Congue Sagittis</span></li>
  <li class="h"><img src="//repo.bfw.wiki/bfwrepo/image/60078a8d5f89d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="sliced watermelons."/><span>Vestibulum Et</span></li>
  <li class="i"><img src="//repo.bfw.wiki/bfwrepo/image/60078a8d5f89d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="grapefruits, lemons, and pomegranates."/><span>Donec Eget</span></li>
  <li class="j"><img src="//repo.bfw.wiki/bfwrepo/image/60078a8d5f89d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="half of an avocado."/><span>Maecenas et Justo</span></li>
  <li class="k"><img src="//repo.bfw.wiki/bfwrepo/image/60078a8d5f89d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="half of a lime."/><span>Malesuada Quam</span></li>
  <li class="l"><img src="//repo.bfw.wiki/bfwrepo/image/60078a8d5f89d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="a single cherry with stem."/><span>Ultricies Sollicitudin</span></li>
  <li class="m"><img src="//repo.bfw.wiki/bfwrepo/image/60078a8d5f89d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="a bunch of bananas."/><span>Gravida Nibh</span></li>
  <li class="n"><img src="https://source.unsplash.com/uI900SItAyY/500x500" alt="three pears."/><span>Pellentesque Sapien</span></li>
  <li class="o"><img src="//repo.bfw.wiki/bfwrepo/image/60078a8d5f89d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="a basket full of peaches next to a plate with sliced peaches."/><span>Suspendisse Vel</span></li>
  <li class="p"><img src="//repo.bfw.wiki/bfwrepo/image/60078a8d5f89d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="a bowl of avocados."/><span>Mauris Consectetur</span></li>
</ul>
<div class="drag-proxy"></div>

  
      <script type="module">
import gsap from 'https://cdn.skypack.dev/gsap';
import ScrollTrigger from 'https://cdn.skypack.dev/gsap/ScrollTrigger';
import Draggable from 'https://cdn.skypack.dev/gsap/Draggable';

gsap.registerPlugin(ScrollTrigger);
gsap.registerPlugin(Draggable);

gsap.set('li', {
  yPercent: -50 });


const STAGGER = 0.1;
const DURATION = 1;
const OFFSET = 0;
const BOXES = gsap.utils.toArray('li');

const LOOP = gsap.timeline({
  paused: true,
  repeat: -1,
  ease: 'none' });


const BEHAVIORS = new Array(BOXES.length).
fill().
map(() => [
gsap.utils.random(-360, 360),
gsap.utils.random(-360, 360),
gsap.utils.random(-250, 250),
gsap.utils.random(-360, 360)]);


const HUES = [
'hsl(20, 60%, 80%)',
'hsl(35, 5%, 80%)',
'hsl(240, 25%, 80%)�.........完整代码请登录后点击上方下载按钮下载查看

网友评论0