Snap.svg README

The project's README from github.com/adobe-webplatform/Snap.svg. As one markdown file: README.md.

Snap.svg · Build Status CDNJS GitHub Tag License

A JavaScript SVG library for the modern web. Learn more at snapsvg.io.

Follow us on Twitter.

Install

Learn

Use

In your HTML file, load simply by:

<script src="snap.svg-min.js"></script>

No other scripts are needed. Both the minified and uncompressed (for development) versions are in the /dist folder.

webpack

To load with webpack 2.x and 3.x, install Imports Loader (npm i -D imports-loader), and add the following to your webpack config:

module: {
  rules: [
    {
      test: require.resolve('snapsvg/dist/snap.svg.js'),
      use: 'imports-loader?this=>window,fix=>module.exports=0',
    },
  ],
},
resolve: {
  alias: {
    snapsvg: 'snapsvg/dist/snap.svg.js',
  },
},

Then, in any module you’d like to require Snap, use:

import Snap from 'snapsvg';

Build

Build Status

Snap.svg uses Grunt to build.

cd Snap.svg
npm install -g grunt-cli

*You might need to use sudo npm, depending on your configuration.

npm install

*Snap.svg uses Grunt 0.4.0. You might want to read more on their website if you haven’t upgraded since a lot has changed.

grunt

Testing

Tests are located in test folder. To run tests, simply open test.html in there. Automatic tests use PhantomJS to scrap this file, so you can use it as a reference.

Alternatively, install PhantomJS and run command

grunt test

Contribute

git checkout -b my_branch
git commit -am "Added some awesome stuff"
git push origin my_branch

Note: Pull requests to other branches than dev or without filled CLA wouldn’t be accepted.

Snap.svg (adobe-webplatform/Snap.svg)

Searching Database…

What is this?Snap.svg is a JavaScript library for creating and animating modern SVG graphics in the browser.
Is it a framework or a library?It's a library you load in your page or bundle with your app; it depends on the small 'eve' event library.
How do I add it to a project?Install with Bower (bower install snap.svg) or npm (npm install snapsvg), or grab the minified/unminified files manually from the dist folder, then just load the script in your HTML - no other scripts needed.
Do I need webpack or any build tool to use it?No, you can just load the script directly in HTML; webpack is only needed if you want to bundle it, in which case you also need the Imports Loader package.
Where does Snap.svg run?It runs in any modern web browser that supports SVG, since it's a client-side JavaScript library.
What can I learn more about Snap.svg from?The project points to snapsvg.io for a Getting Started guide, an API Reference, and a Slack room for community help.
Why would I use Snap.svg instead of raw SVG manipulation?It provides a higher-level JavaScript API for creating, animating and manipulating SVG elements, saving you from writing verbose raw DOM/SVG code by hand.
What are similar projects?lottie-web, mojs, raphael, zdog, lenis, d3, plotly.js, twemoji
Size
3.7 MB
Stars
14K
Updated
CommitMar 13
Age
13y
Commits · 90 Days