1.0.6 • Published 7 years ago
svg-elem v1.0.6
svg-elem
Generic animatable svg elements.
Examples
Installation
npm i svg-elemUsage
import SvgElem from 'svg-elem'
const svg = new SvgElem({
parentDom: document.getElementById('root'),
tag: 'svg',
attr: {
'width': 500,
'height': 500,
},
style: {
'background': '#eee',
},
})
const circle = new SvgElem({
parentDom: svg.elem,
tag: 'circle',
attr: {
'cx': 250,
'cy': 250,
'r': 50,
},
style: {
'fill': 'white',
'stroke': 'black',
'stroke-width': '2px',
},
})Required Props
Props you must specify:
parentDom- the DOM element that contains your elementtag- element name of the SVG
Optional Props
Props you can optionally specify:
attr- SVG element attributesstyle- SVG element stylestext- text content for svg texts
Methods
Methods you can specify:
setAttr(oParam, shouldAnimate)- updates SVG's attributessetStyle(oParam, shouldAnimate)- updates SVG's styles