GithubHelp home page GithubHelp logo

svgpan's Introduction

svgpan

Tiny Javascript to add pan, zoom & drag capabilities to SVG.

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 :(

Since I couldn't find anything around, I've decided to write a minimalistic javascript library to provide such interactions, so SVGPan was born!

Features:

  • Panning (pan à la Google maps) (click on the white background and pan)
  • Zooming (using the mouse wheel)
  • Element dragging (click on a drawing element and drag it somewhere else)
  • Combinations of the above like zooming while dragging

The library itself is very small and easy to use; and it’s licensed under the BSD license. You can try a demo.

Quickstart

You can install svgpan via bower:

bower install svgpan

Alternatively just download svgpan.js into your application.

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:

<script xlink:href="svgpan.js"/>

<g id="viewport" transform="translate(200,200)">...

svgpan's People

Contributors

aleofreddi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.