├── .gitignore ├── bower.json ├── package.json ├── README.md ├── svgpan.js └── tiger.svg /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svgpan", 3 | "description": "Tiny javascript library to add pan, zoom & drag capabilities to SVG", 4 | "main": "svgpan.js", 5 | "authors": [ 6 | "Andrea Leofreddi" 7 | ], 8 | "license": "BSD-3-Clause", 9 | "keywords": [ 10 | "svg", 11 | "pan", 12 | "zoom", 13 | "drag" 14 | ], 15 | "homepage": "https://github.com/aleofreddi/svgpan", 16 | "ignore": [ 17 | "**/.*", 18 | "node_modules", 19 | "bower_components", 20 | "test", 21 | "tests" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svgpan", 3 | "version": "1.2.2", 4 | "description": "Tiny javascript library to add pan, zoom & drag capabilities to SVG", 5 | "main": "svgpan.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/aleofreddi/svgpan.git" 9 | }, 10 | "keywords": [ 11 | "svg", 12 | "pan", 13 | "zoom", 14 | "drag" 15 | ], 16 | "author": "Andrea Leofreddi", 17 | "license": "BSD-3-Clause", 18 | "bugs": { 19 | "url": "https://github.com/aleofreddi/svgpan/issues" 20 | }, 21 | "homepage": "https://github.com/aleofreddi/svgpan#readme", 22 | "dependencies": { 23 | "bower": "^1.8.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # svgpan 2 | Tiny Javascript to add pan, zoom & drag capabilities to SVG. 3 | 4 | Some time ago I had a need to display some vectorial drawings on the web so I've found out that SVG is decently supported by modern browsers (I won’t say anything about Internet Explorer – it’s just unsupported there). The language itself is great, but the interactivity provided by the browsers is definitely low: can display your SVG file on a browser and that's it - you can't navigate it, zoom it or pan :( 5 | 6 | Since I couldn't find anything around, I've decided to write a minimalistic javascript library to provide such interactions, so SVGPan was born! 7 | 8 | Features: 9 | 10 | - Panning (pan à la Google maps) (click on the white background and pan) 11 | - Zooming (using the mouse wheel) 12 | - Element dragging (click on a drawing element and drag it somewhere else) 13 | - Combinations of the above like zooming while dragging 14 | 15 | The library itself is very small and easy to use; and it’s licensed under the BSD license. You can try a [demo](http://www.vleo.net/docs/projects/SVGPan/tiger.svg). 16 | 17 | ## Quickstart 18 | You can install svgpan via [bower](http://bower.io): 19 | 20 | ``` 21 | bower install svgpan 22 | ``` 23 | 24 | Alternatively just download svgpan.js into your application. 25 | 26 | The library requires a root group to be identified by the id `viewport`, which is where the svg/pan/zoom will be applied. Below an example: 27 | 28 | ```html 29 |