gsap实现上传按钮点击波浪抖动动画效果代码

代码语言:html

所属分类:上传

代码描述:gsap实现上传按钮点击波浪抖动动画效果代码

代码标签: gsap 上传 按钮 点击 波浪 抖动

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


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

<head>

  <meta charset="UTF-8">
  


  <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&amp;display=swap'>
  
<style>
.upload-button {
  font-family: "Poppins", Arial;
  font-size: 16px;
  font-weight: 600;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  color: #fff;
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  width: 128px;
  padding: 0;
  margin: 0;
  text-align: center;
  line-height: 20px;
  position: relative;
  filter: drop-shadow(0px 4px 12px rgba(118, 70, 215, 0.1));
  transform: translateZ(0);
}
.upload-button > svg {
  display: block;
  width: 132px;
  height: 52px;
  fill: #7646d7;
  pointer-events: none;
  margin: -4px -2px;
  transition: fill 0.2s, transform 0.1s;
  transform: translateZ(0);
}
.upload-button:hover > svg {
  fill: #6f3bda;
}
.upload-button:active > svg {
  transform: scale(0.975) translateZ(0);
}
.upload-button .default,
.upload-button .success {
  top: 12px;
  bottom: 12px;
  left: 0;
  right: 0;
  position: absolute;
  display: block;
  z-index: 1;
}
.upload-button .default > div,
.upload-button .success > div {
  display: inline-block;
  vertical-align: top;
}
.upload-button .default > div > div span,
.upload-button .success > div > div span {
  display: inline-block;
  vertical-align: top;
  transform-origin: 50% 100%;
  transform: translateZ(0);
}
.upload-button .success svg {
  width: 13px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-width: 2;
  display: inline-block;
  vertical-align: top;
  margin: 5px 4px 5px 0;
  stroke-dasharray: 17px;
  stroke-dashoffset: 17px;
  transform: translateZ(0);
}
.upload-button .success > div > div span {
  opacity: 0;
  transform: scale(0.25) translateZ(0);
}
.upload-button .dots {
  top: 19px;
  bottom: 19px;
  left: 0;
  right: 0;
  position: absolute;
  display: flex;
  justify-content: center;
  z-index: 1;
}
.upload-button .dots span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  margin: 0 3px;
  transform: translateY(6px) scale(0);
}

html {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: inherit;
}
*:before, *:after {
  box-sizing: inherit;
}

body {
  min-height: 100vh;
  display: flex;
  font-family: "Poppins", Arial;
  justify-content: center;
  align-items: center;
  background-color: #fdf9f7;
}
body .twitter {
  position: fixed;
  display: block;
  right: 12px;
  bottom: 12px;
}
body .twitter svg {
  width: 32px;
  height: 32px;
  fill: #1da1f2;
}
</style>


</head>

<body >
  <button class="upload-button">
  <div class="default">
    <div>Upload</div>
  </div>
  <div class="success">
    <svg viewBox="0 0 13 10">
      <path d="M1 5L4.66667 9L12 1" />
    </svg>
    <div>Done</div>
  </div>
  <div class="dots">
    <span></span>
    <span></span>
    <span></span>
    <span></span>
    <span></span>
  </div>
  <svg viewBox="0 0 132 52">
    <path
      d="M2 11C2 7.13401 5.13401 4 9 4C12.866 4 39.7401 4 66 4C92.2599 4 119.134 4 123 4C126.866 4 130 7.13401 130 11V41C130 44.866 126.866 48 123 48C119.134 48 92.2599 48 66 48C39.7401 48 12.866 48 9 48C5.13401 48 2 44.866 2 41V11Z"
    />
  </svg>
</button>

<!-- twitter -->
<a class="twitter" target="_top" href="https://twitter.com/aaroniker_me"><svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" viewBox="0 0 72 72"><path d="M67.812 16.141a26.246 26.246 0 0 1-7.519 2.06 13.134 13.134 0 0 0 5.756-7.244 26.127 26.127 0 0 1-8.313 3.176A13.075 13.075 0 0 0 48.182 10c-7.229 0-13.092 5.861-13.092 13.093 0 1.026.118 2.021.338 2.981-10.885-.548-20.528-5.757-26.987-13.679a13.048 13.048 0 0 0-1.771 6.581c0 4.542 2.312 8.551 5.824 10.898a13.048 13.048 0 0 1-5.93-1.638c-.002.055-.002.11-.002.162 0 6.345 4.513 11.638 10.504 12.84a13.177 13.177 0 0 1-3.449.457c-.846 0-1.667-.078-2.465-.231 1.667 5.2 6.499 8.986 12.23 9.09a26.276 26.276 0 0 1-16.26 5.606A26.21 26.21 0 0 1 4 55.976a37.036 37.036 0 0 0 20.067 5.882c24.083 0 37.251-19.949 37.251-37.249 0-.566-.014-1.134-.039-1.694a26.597 26.597 0 0 0 6.533-6.774z"></path></svg></a>


<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.9.1.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/MorphSVGPlugin3.min.js"></script>
      <script  >
const { to, set } = gsap;

gsap.registerPlugin(MorphSVGPlugin);

document.querySelectorAll(".upload-button").forEach((button) => {
  const path = button.querySelector(":scope > svg path");
  const dots = button.querySelectorAll(".dots span");

  button
    .querySelectorAll(".default > div, .success > div")
    .forEach(
      (state) =>
        (state.innerHTML =
          "<div><span>" +
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0