Path Transition with little JS code, render to anywhere - 轻量级 Path 过渡库,渲染到任何地方
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Latest commit d1f9c45 Jul 8, 2018
Permalink
Failed to load latest commit information.
dist fix _subShapes Sep 1, 2017
docs update doc Jun 27, 2017
example update doc Jun 26, 2017
src fix _subShapes Sep 1, 2017
.babelrc support A and a of svg path Jun 15, 2017
.gitattributes Create .gitattributes Jun 15, 2017
README.md Update README.md Jul 8, 2018
index.html update html Jun 21, 2017
package.json fix #2 Jun 21, 2017
rollup.config.js support A and a of svg path Jun 15, 2017

README.md

pasitionpasition

Pasition - Path Transition with little JS code, render to anywhere.


中文 README

DEMO

Install

npm install pasition

or get js by the cdn address:

https://unpkg.com/pasition@1.0.1/dist/pasition.js

Usage

pasition.animate({
    from : fromPath,
    to : toPath,
    time : time,
    easing : function(){ },
    begin :function(shapes){ },
    progress : function(shapes, percent){ },
    end : function(shapes){ }
})

you can get the path from attr d of svg path element.

Supported All the svg path commands:

M/m = moveto
L/l = lineto
H/h = horizontal lineto
V/v = vertical lineto
C/c = curveto
S/s = smooth curveto
A/a = elliptical Arc
Z/z = closepath
Q/q = quadratic Belzier curve
T/t = smooth quadratic Belzier curveto

Example:

pasition.animate({
    from: 'M 40 40 Q 60 80 80 40T 120 40 T 160 40 z',
    to: 'M32,0C14.4,0,0,14.4,0,32s14.3,32,32,32 s32-14.3,32-32S49.7,0,32,0z',
    time: 1000,
    easing : function(){ },
    begin:function(shapes){ },
    progress : function(shapes, percent){
        //render you shape to svg or canvas or webgl
    },
    end : function(shapes){ }
});

you can get the progressing shapes by pasition.lerp:

var shapes  = pasition.lerp(pathA, pathB, 0.5)
//render shapes in canvas ,svg or anywhere you want
...

License

This content is released under the MIT License.