react实现三维爱心表白鼠标交互效果代码

代码语言:html

所属分类:表白

代码描述:react实现三维爱心表白鼠标交互效果代码

代码标签: react 三维 爱心 表白

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">


    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">




    <style>
        body {
          width: 100vw;
          height: 100vh;
          font-family: "Montserrat", sans-serif;
          background-image: radial-gradient(circle, #edc9db, #f391c3);
        }
        
        .app {
          width: 100vw;
          height: 100vh;
          display: grid;
          align-items: center;
          justify-content: center;
        }
        
        .heart {
          perspective: 1000px;
          width: 100px;
          height: 100px;
          border: none;
          background: none;
          cursor: pointer;
          outline: none;
        }
        .heart::after {
          content: "";
          position: absolute;
          border-radius: 100%;
          left: 10%;
          bottom: -20%;
          width: 80%;
          height: 20%;
          background-color: rgba(179, 77, 121, 0.4);
          filter: blur(5px);
          transform: scale(var(--scale));
        }
        .heart svg {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          overflow: visible;
        }
        .heart .inner-wrapper {
          width: 100%;
          height: 100%;
          transform: scale(var(--scale));
          transition: 0.1s ease-out;
        }
        .heart .splash {
          width: 100%;
          height: 100%;
        }
        .heart .splash path {
          stroke: #ebadc8;
          stroke-width: 0;
          fill: none;
          transform-origin: center;
          animation-timing-function: linear;
          animation-duration: 0.5s;
          animation-name: splash;
        }
        .heart .heart-stroke {
          fill: none;
          stroke: white;
          stroke-width: 20px;
          stroke-dasharray: 300 1206;
          stroke-linecap: round;
        }
        .heart .heart-layer {
          transition: fill 0.3s ease-out;
          fill: hsl(334deg, var(--lightness), 50%);
          stroke: hsl(334deg, var(--lightness), 35%);
          stroke-width: 10px;
        }
        .heart .heart-shine {
          filter: blur(3px);
        }
        
        @keyframes splash {
          0% {
            transform: scale(0.1);
            stroke-width: 0;
          }
          30% {
            transform: scale(1);
            stroke-width: 50;
          }
          100% {
            transform: scale(2);
            stroke-width: 1;
          }
        }
    </style>

  

</head>

<body >

  

  <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/babel.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.17.1.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-dom.production.17.1.js"></script>
      <script type="text/babel">
      
            
const {react, useState,useRef,useEffect,memo} = window.React;
  const { render,reactdom  } = window.ReactDOM;


const PATH_LENGTH = 1506;
const LAYERS = 20;
const LAYER_GAP = 2; // In pixels

const clamp = (min, max, n) => (
  Math.min(max, Math.max(min, n))
);

const useDocumentEvent = (event, handler) => {
  useEffect(() => {
    const events = event.split(' ');
    events.forEach(event => document.addEventListener(event, handler));
    return () => events.forEach(event => document.removeEventListener(event, handler));
  }, []);
};

const useTimeArray = delay => {
  const [timestamps, setTimestamps] = useState([]);
  const timeout = useRef();
  useEffect(() => {
    return () => clearTimeout(timeout.current);
  }, []);
  return {timestamps, add: () => {
    setTimestamps(arr => [...arr, Date.now()]);
    timeout.current = setTimeout(() => setTimestamps(arr => arr.filter(t => Date.no.........完整代码请登录后点击上方下载按钮下载查看

网友评论0