Giter Site home page Giter Site logo

like-heart's Introduction

Canvas点赞送心组件

特性

  • 配置项多,定制化强
  • 基于canvas效果,性能更强
  • 使用简单方便

示例

使用方法

    let img = new Image();
    img.src = './img/like0'+Math.ceil(Math.random()*3)+'.png';


    let p1 = {
        x: 100 + getRandomDis(),
        y: 300 + getRandomDis()
    };

    let p2 = {
        x: 100 + getRandomDis(),
        y: 200 + getRandomDis()
    };

    new LikeHeart({
        id: heartCount,
        x: 200,
        y: 200,
        endX: 200,
        endY: 200,
        onFadeOut: removeItem,

        width: 66,
        height: 66,
        image: img,
        bezierPoint: {
            p0: {
                x: 200,
                y: 200
            },

            p1: p1,
            p2: p2,
            p3: {
                x: 200,
                y: 200
            }
        }
    });

配置说明

参数 类型 描述 必需 默认值
object.x         number     心起点位置x
object.y number 心起点位置y
object.endX number 心结束位置x
object.endY number 心结束位置x
object.height number
object.width         number    
object.angelEnd number 左右摇摆起始角度 -20
object.angelBegin number 左右摇摆结束角度 20
object.noScale         bool 是否使用缩放心动画
object.scaleDis number 缩放心临界值(默认从起始位置到升高50) 50
object.noFadeOut bool 是否使用fadeOut
object.opacityDis number 缩放心临界值(默认从起始位置到升高50) 50
object.speed number 上升速度 0.023
object.bezierPoint         number     贝塞尔曲线4个点的值
object.onFadeOut         function     每个心fadeOut之后回调
object.image         obj     图片对象

License

Licensed under MIT license.

like-heart's People

Contributors

lvming6816077 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.