TweenLite实现canvas线条跟随鼠标移动视觉差异动画代码

代码语言:html

所属分类:视觉差异

代码描述:TweenLite实现canvas线条跟随鼠标移动视觉差异动画代码

代码标签: TweenLite canvas 线条 跟随 鼠标 移动 视觉差异

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

<!doctype html>
<html>

<head>
    <meta charset="utf-8">


    <style>
        html {
          height: 100%;
        }
        
        main {
          height: 100%;
        }
        
        body {
          height: 100%;
          background: #02020e;
          min-height: 100vh;
          overflow: hidden;
        }
        
        .canvas-wrap {
          height: 100%;
          width: 100%;
          z-index: 3;
        }
        .canvas-wrap .shadow-left {
          position: absolute;
          width: 80px;
          height: 100%;
          top: 0;
          left: 0;
          z-index: 1;
          background-image: linear-gradient(to left, rgba(9, 1, 24, 0) 0%, #090118 100%);
        }
        .canvas-wrap .shadow-right {
          position: absolute;
          width: 80px;
          height: 100%;
          top: 0;
          right: 0;
          z-index: 1;
          background-image: linear-gradient(to right, rgba(9, 1, 24, 0) 0%, #090118 100%);
        }
        .canvas-wrap .shadow-top {
          position: absolute;
          width: 100%;
          height: 80px;
          top: 0;
          left: 0;
          z-index: 1;
          background-image: linear-gradient(to top, rgba(9, 1, 24, 0) 0%, #090118 100%);
        }
        .canvas-wrap .shadow-bottom {
          position: absolute;
          width: 100%;
          height: 80px;
          bottom: 0;
          left: 0;
          z-index: 1;
          background-image: linear-gradient(to bottom, rgba(9, 1, 24, 0) 0%, #090118 100%);
        }
        .canvas-wrap:before {
          content: "";
          position: absolute;
          width: 80px;
          height: 100%;
          top: 0;
          right: 0;
          z-index: 1;
          background-image: linear-gradient(to right, rgba(9, 1, 24, 0) 0%, #090118 100%);
        }
        .canvas-wrap img {
          display: block;
          width: 100%;
          height: 100%;
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          z-index: 1;
          opacity: 0;
          transition: opacity 1s ease 0.3s;
        }
        .canvas-wrap img.loaded {
          opacity: 1;
        }
    </style>
</head>

<body>

    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/TweenLite.js"></script>
    <main id="main" data-page-id="home">
        <div class="canvas-wrap">
            <canvas id="canvas"></canvas>
            <div class="shadow-left"></div>
            <div class="shadow-right"></div>
            <div class="shadow-bottom"></div>
            <div class="shadow-top"></div>
        </div>
    </main>


    <script>
        const MOBILE_DEVICE_SCREEN_WIDTH = 690;
        const FULL_HD_DEVICE_SCREEN_WIDTH = 1920;
        const img = document.getElementById('img');
        
        class Director {
        
            _setup() {
                this._el = document.getElementById('main');
                this.rect = this._el.getBoundingClientRect();
        
                this.onMouseMove = this.onMouseMove.bind(this);
                this.onMouseLeave = this.onMouseLeave.bind(this);
                this.resize = this.resize.bind(this);
        
                this.isMobile = false;
                this.isFullHD =.........完整代码请登录后点击上方下载按钮下载查看

网友评论0