Giter Site home page Giter Site logo

svg.resize.js's Introduction

svg.resize.js

An extension of svg.js which allows to resize elements which are selected with svg.select.js

Demo

For a demo see http://svgdotjs.github.io/svg.resize.js/

Get Started

  • Install svg.resize.js using bower:

      bower install svg.resize.js
    
  • Include the script after svg.js and svg.select.js into your page

      <script src="svg.js"></script>
      <script src="svg.select.js"></script>
      <script src="svg.resize.js"></script>
    
  • Select a rectangle and make it resizeable:

      <div id="myDrawing"></div>
    
      var drawing = new SVG('myDrawing').size(500, 500);
      drawing.rect(50,50).selectize().resize()
    

Usage

Activate resizing

var draw = SVG('drawing');
var rect = draw.rect(100,100);
rect.selectize().resize();

Deactivate resizing

rect.resize('stop');

Keep element within constrained box

var draw = SVG('drawing');
var rect = draw.rect(100, 100);
var opt = {
	constraint: {
		minX: 0,
		minY: 0,
		maxX: 200,
		maxY: 300
	}
};
rect.selectize().resize(opt)

Options

  • snapToGrid: Snaps the shape to a virtual grid while resizing (default 1)
  • snapToAngle: Snaps to an angle when rotating (default 0.1)
  • constraint: Keep element within constrained box (see usage above); The box snaps to the grid defined by snapToGrid.
  • saveAspectRatio: Save aspect ratio of the element while resizing with left-top, left-bottom, right-top, right-bottom points.

Events

  • resizing: Fired when changes occur
  • resizedone: Fired when resizing is done

Known Issues

  • resize nested svgs does not work

svg.resize.js's People

Contributors

clusterberries avatar diruuu avatar fuzzyma avatar guskis avatar johnhardy avatar maxmitti avatar suilaiji 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.