0.1.5 • Published 6 years ago
svg-animation-player v0.1.5
Svg Animation Player
Simple animation library for SVG. With player included.
Install
NPM
For module bundlers (webpack, rollup, parcel...)
$ npm install svg-animation-player --saveCDN
In your HTML file, load simply by:
<script src="https://cdn.jsdelivr.net/npm/svg-animation-player@0.1.5/dist/svganimationplayer.min.js"></script>Manual
Download file https://raw.githubusercontent.com/M-51/svg-animation-player/master/dist/svganimationplayer.min.js
Your HTML:
<script src="svganimationplayer.min.js"></script>Usage
SVG:
<svg viewBox="-100 -100 200 200" xmlns="http://www.w3.org/2000/svg">
<rect id="test1" x="-10" y="-10" width="20" height="20" transform="translate(0, 100)"/>
</svg>Javascript:
const test = new SVGAnimationPlayer({
interfaceColor: '#666',
});
test.add({
object: '#test1',
animation: {
transform: [{
range: [0, 1],
translate: {
x: {
to: 150,
},
y: t => 100 + 20 * t,
},
rotate: {
to: 2 * Math.PI,
},
}, {
range: [1, 2],
easing: 'easeInOutCubic',
translate: {
x: {
to: 0,
},
},
}],
opacity: [{
range: [0, 0.5],
value: {
from: 1,
to: 0.5,
},
}, {
range: [1.5, 2],
value: {
to: 1,
},
}],
},
});Options
showInterface- Boolean (True/False), default -True, Enable or disable interfaceinterfaceAnimation- Boolean (True/False), default -True, Enable or disable interface animationinterfaceSize- Number (0 - 10), default -1, Size of interfaceinterfaceColor- Color (HTML color or "none"), default -#000, Color of interface ornone- Use CSS to styleinterfacePosition- Array (x, y) orauto(bottom left), defaultauto, Position of interface
Methods
SVGAnimationPlayer.play()- Start animationSVGAnimationPlayer.pause()- Pause animationSVGAnimationPlayer.end()- End animationSVGAnimationPlayer.refresh()- Refresh animationSVGAnimationPlayer.add()- Add objects to animation