TweenMa实现鼠标跟随彩带飘动动画效果代码

代码语言:html

所属分类:动画

代码描述:TweenMa实现鼠标跟随彩带飘动动画效果代码,结合了rxjs

代码标签: 跟随 彩带 飘动 动画 效果

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

<html lang="en">
<head>

    <meta charset="UTF-8">






    <style>
        html, body {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            padding: 0;
            background-color: black;
        }

        #app {
            width: 100%;
            height: 100%;
        }
    </style>




    <style>
        .sg {
            width: 35px;
            height: 35px;
            position: fixed;
            bottom: 10px;
            right: 10px;
        }

        .sg .eye {
            -webkit-transform: translateX(0px);
            transform: translateX(0px);
        }

        .sg:hover .eye {
            -webkit-transition: -webkit-transform 0.3s ease;
            transition: -webkit-transform 0.3s ease;
            transition: transform 0.3s ease;
            transition: transform 0.3s ease, -webkit-transform 0.3s ease;
            -webkit-transform: translateX(12px);
            transform: translateX(12px);
        }
    </style>
</head>

<body>
    <div id="app">
        <svg id="stage" width="367" height="756" xmlns="http://www.w3.org/2000/svg"><path d="" style="fill: red;"></path><path d="" style="fill: blue;"></path><path d="" style="fill: green;"></path><path d="" style="fill: yellow;"></path><path d="" style="fill: white;"></path></svg>
    </div>


  
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/TweenMax.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/Rx.5.0.1.js"></script>
    <script id="rendered-js">
        "use strict";
       
        console.clear();
        class App {
            constructor(container) {
                this.width = 600;
                this.height = 600;
                this.followers = [];
                this.colors = ['red',
                    'blue',
                    'green',
                    'yellow',
                    'white'];
                this.previewMode = false;
                this.record = false;
                this.recording = [];
                console.log('APP STARTED');
                this.previewMode = location.pathname.match(/fullcpgrid/i);
                this.container = container;
                this.svg = document.getElementById('stage');
                window.addEventListener('resize', () => this.onResize());
                this.onResize();
                this.colors.map(color => this.followers.push(new Follower(this.svg, color)));
                let input = new Input(this.container);
                input.starts.subscribe(() => {
                    this.recording = [];
                    this.record = true;
                });
                input.ends.subscribe(() => {
                    this.record = false;
                    console.clear();
                    console.log(JSON.stringify(this.recording));
                });
                input.moves
                .distinctUntilChanged((a, b) => a.x == b.x && a.y == b.y)
                .subscribe((position) => {
                    if (this.autoMouse)
                        this.autoMouse.unsubscribe();
                    this.followers.map(follower => follower.add(position));
                    if (this.record) {
                        this.recording.push({
                            x: (position.x / this.width) * 100,
                            y: (position.y / this.height) * 100
                        });
                    }
                });
                let path = [{
                    "x": 48.47222222222222, "y": 50.30581039755352
                }, {
                    "x": 48.19444444444444, "y": 51.52905198776758
                }, {
                    "x": 47.5, "y": 53.36391437308868
                }, {
                    "x": 46.111111111111114, "y": 55.35168195718655
                }, {
                    "x": 44.375, "y": 56.574923547400616
                }, {
                    "x": 42.36111111111111, "y": 57.3394495412844
                }, {
                    "x": 40.13888888888889, "y": 57.3394495412844
                }, {
                    "x": 38.54166666666667, "y": 57.3394495412844
                }, {
                    "x": 36.52777777777778, "y": 53.97553516819572
                }, {
                    "x": 36.18055555555556, "y": 52.90519877675841
                }, {
                    "x": 35.34722222222222, "y": 47.55351681957187
                }, {
                 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0