Include Snap.svg 0.4.1 and snap-animation-states.js in the footer. No JQuery needed.
<script type="text/javascript" src="js/snap.svg.js">
<script type="text/javascript" src="js/snap-animation-states.js">
Your SVGs need a container element. You just need to add whatever class you're calling your svg with to the element that will contain it.
<i class="icon-hamburger"></i>
<i class="my-svg-selector"></i>
It's as simple as calling the plugin with the correct schema.
(function() {
SnapStates({ ...schema... })
})();
selector: string css selector - ex: ".icon-hamburger"svg: string svg string or svg file referenceeasing: string "linear", "easein", "easeout", "easeinout", "backin", "backout", "bounce", "elastic"transitionTime: intTransition time is applied to each transform. A state with 3 transforms one after the other and a transitionTime of 500 ms will take a total of 1500 ms to finishinitState: stringSet initState equal to the state you want to run when the plugin is called.states: obj Contains the states and transforms to be performed. Each state contains an array of transforms.key: state nameprop: array of transform objectsid: int/string/arr The id should be unique to its state. If you want the transform to start after a timeout, the id takes an array: [id, timeout:int]waitFor: int/string/arr Set the waitFor property to the id of a transform that it should follow. For a timeout, waitFor takes an array: [id, timeout: int]element: string Takes the css selector of the element that the transform is affecting.x: int Takes an x coordinate relative to the elements starting positiony: int Takes a y coordinate relative to the elements starting positionr: int/arrays: int/arrayattr: obj Affect any svg attributepath: string Represented by the "d" attribute in an svg. Learn more about paths.drawPath: int/objtransitionTime: int/objeasing: stringsame easing options as previously shown. Useful if you have several types of easing you want to display from transform to transformrepeat: obj Will repeat the entire state from the point the repeat is calledloop :bool set an infinite looploopDuration :int end loop after a timetimes: int loop the animation x timesevents:array of objectsevent: string works with any javascript eventstate: string/arrayselector: string a css selector used to indicate where to watch for the event - ex: an svg inside an anchor tag. The anchor tag will receive the selector so that when the anchor is clicked the svg animation runs.Interested in building your own animated svg library? Check out gulp-animation-states to see how you can quickly and easily combine svg and js into a single js file, allowing you to call your SVGs like any font icon.