gsap+ScrollTrigger+Draggable实现支持鼠标滚动键盘及拖动操作的炫酷三维图片相册切换效果代码

代码语言:html

所属分类:画廊相册

代码描述:gsap+ScrollTrigger+Draggable实现支持鼠标滚动键盘及拖动操作的炫酷三维图片相册切换效果代码,支持背景颜色与图片主色自动适配,支持键盘左右切换、支持手机端拖放操作。

代码标签: gsap ScrollTrigger Draggable 鼠标 滚动 键盘 拖动 三维 图片 相册

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

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

<head>
    <meta charset="UTF-8">
    
    <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.css">
<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: 30vmin;
  width: 30vmin;
  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>
    <!-- partial:index.partial.html -->
    <ul>
        <li class="a"><img src="//repo.bfw.wiki/bfwrepo/image/627ef07191c49.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="cut citrus fruits." /><span>Lorem Ipsum</span></li>
        <li class="b"><img src="//repo.bfw.wiki/bfwrepo/image/62842707b1cc9.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="sliced mango." /><span>Dolor Sit</span></li>
        <li class="c"><img src="//repo.bfw.wiki/bfwrepo/image/6284273e2b668.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="a bunch of blueberries." /><span>Amet Consectetur</span></li>
        <li class="d"><img src="//repo.bfw.wiki/bfwrepo/image/628427972e557.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/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/628427e09d621.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="frozen raspberries." /><span> Nunc Tortor</span></li>
        <li class="f"><img src="//repo.bfw.wiki/bfwrepo/image/628427c4ca32c.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="a sliced strawberry." /><span>Metus Mollis</span></li>
        <li class="g"><img src="//repo.bfw.wiki/bfwrepo/image/6284286d59cbd.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/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/6284309a1b4e3.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="sliced watermelons." /><span>Vestibulum Et</span></li>
        <li class="i"><img src="//repo.bfw.wiki/bfwrepo/image/6284325120d66.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="grapefruits, lemons, and pomegranates." /><span>Donec Eget</span></li>
        <li class="j"><img src="//repo.bfw.wiki/bfwrepo/image/6284327a47c4c.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="half of an avocado." /><span>Maecenas et Justo</span></li>
        <li class="k"><img src="//repo.bfw.wiki/bfwrepo/image/628432ce5b47a.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="half of a lime." /><span>Malesuada Quam</span></li>
        <li class="l"><img src="//repo.bfw.wiki/bfwrepo/image/6284333f58221.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="a single cherry with stem." /><span>Ultricies Sollicitudin</span></li>
        <li class="m"><img src="//repo.bfw.wiki/bfwrepo/image/62843353e6a73.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="a bunch of bananas." /><span>Gravida Nibh</span></li>
        <li class="n"><img src="//repo.bfw.wiki/bfwrepo/image/6284337bbaf11.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="three pears." /><span>Pellentesque Sapien</span></li>
        <li class="o"><img src="//repo.bfw.wiki/bfwrepo/image/628434d826be9.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/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/628434d826be9.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300,/quality,q_90" alt="a bowl of avocados." /><span>Mauris Consectetur</span></li>
    </ul>
    <div class="drag-proxy"></div>
    <!-- partial -->
    <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/gsap.3.10.1.js"></script>

    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/Draggable3.min.js"></script>
    <script>

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 X_START = 200;
const X_FINISH = -300;
const Y_START = -150;
const Y_FINI.........完整代码请登录后点击上方下载按钮下载查看

网友评论0