New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

svg.resize.js

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg.resize.js - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

15

dist/svg.resize.js

@@ -1,4 +0,12 @@

/*! svg.resize.js - v1.4.0 - 2016-09-15
* https://github.com/Fuzzyma/svg.resize.js
* Copyright (c) 2016 Ulrich-Matthias Schäfer; Licensed MIT */
/*!
* svg.resize.js - An extension for svg.js which allows to resize elements which are selected
* @version 1.4.1
* https://github.com/svgdotjs/svg.resize.js
*
* @copyright [object Object]
* @license MIT
*/;
;(function() {
"use strict";
;(function () {

@@ -446,1 +454,2 @@

}).call(this);
}());

@@ -1,4 +0,1 @@

/*! svg.resize.js - v1.4.0 - 2016-09-15
* https://github.com/Fuzzyma/svg.resize.js
* Copyright (c) 2016 Ulrich-Matthias Schäfer; Licensed MIT */
(function(){function a(a){a.remember("_resizeHandler",this),this.el=a,this.parameters={},this.lastUpdateCall=null,this.p=a.doc().node.createSVGPoint()}a.prototype.transformPoint=function(a,b,c){return this.p.x=a-(this.offset.x-window.pageXOffset),this.p.y=b-(this.offset.y-window.pageYOffset),this.p.matrixTransform(c||this.m)},a.prototype._extractPosition=function(a){return{x:a.clientX||a.touches[0].pageX,y:a.clientY||a.touches[0].pageY}},a.prototype.init=function(a){var b=this;if(this.stop(),"stop"!==a){this.options={};for(var c in this.el.resize.defaults)this.options[c]=this.el.resize.defaults[c],"undefined"!=typeof a[c]&&(this.options[c]=a[c]);this.el.on("lt.resize",function(a){b.resize(a||window.event)}),this.el.on("rt.resize",function(a){b.resize(a||window.event)}),this.el.on("rb.resize",function(a){b.resize(a||window.event)}),this.el.on("lb.resize",function(a){b.resize(a||window.event)}),this.el.on("t.resize",function(a){b.resize(a||window.event)}),this.el.on("r.resize",function(a){b.resize(a||window.event)}),this.el.on("b.resize",function(a){b.resize(a||window.event)}),this.el.on("l.resize",function(a){b.resize(a||window.event)}),this.el.on("rot.resize",function(a){b.resize(a||window.event)}),this.el.on("point.resize",function(a){b.resize(a||window.event)}),this.update()}},a.prototype.stop=function(){return this.el.off("lt.resize"),this.el.off("rt.resize"),this.el.off("rb.resize"),this.el.off("lb.resize"),this.el.off("t.resize"),this.el.off("r.resize"),this.el.off("b.resize"),this.el.off("l.resize"),this.el.off("rot.resize"),this.el.off("point.resize"),this},a.prototype.resize=function(a){var b=this;this.m=this.el.node.getScreenCTM().inverse(),this.offset={x:window.pageXOffset,y:window.pageYOffset};var c=this._extractPosition(a.detail.event);if(this.parameters={type:this.el.type,p:this.transformPoint(c.x,c.y),x:a.detail.x,y:a.detail.y,box:this.el.bbox(),rotation:this.el.transform().rotation},"text"===this.el.type&&(this.parameters.fontSize=this.el.attr()["font-size"]),void 0!==a.detail.i){var d=this.el.array().valueOf();this.parameters.i=a.detail.i,this.parameters.pointCoords=[d[a.detail.i][0],d[a.detail.i][1]]}switch(a.type){case"lt":this.calc=function(a,b){var c=this.snapToGrid(a,b);if(this.parameters.box.width-c[0]>0&&this.parameters.box.height-c[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+c[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-c[0]);this.el.move(this.parameters.box.x+c[0],this.parameters.box.y+c[1]).size(this.parameters.box.width-c[0],this.parameters.box.height-c[1])}};break;case"rt":this.calc=function(a,b){var c=this.snapToGrid(a,b,2);if(this.parameters.box.width+c[0]>0&&this.parameters.box.height-c[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-c[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+c[0]);this.el.move(this.parameters.box.x,this.parameters.box.y+c[1]).size(this.parameters.box.width+c[0],this.parameters.box.height-c[1])}};break;case"rb":this.calc=function(a,b){var c=this.snapToGrid(a,b,0);if(this.parameters.box.width+c[0]>0&&this.parameters.box.height+c[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-c[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+c[0]);this.el.move(this.parameters.box.x,this.parameters.box.y).size(this.parameters.box.width+c[0],this.parameters.box.height+c[1])}};break;case"lb":this.calc=function(a,b){var c=this.snapToGrid(a,b,1);if(this.parameters.box.width-c[0]>0&&this.parameters.box.height+c[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+c[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-c[0]);this.el.move(this.parameters.box.x+c[0],this.parameters.box.y).size(this.parameters.box.width-c[0],this.parameters.box.height+c[1])}};break;case"t":this.calc=function(a,b){var c=this.snapToGrid(a,b,2);if(this.parameters.box.height-c[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y+c[1]).height(this.parameters.box.height-c[1])}};break;case"r":this.calc=function(a,b){var c=this.snapToGrid(a,b,0);if(this.parameters.box.width+c[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).width(this.parameters.box.width+c[0])}};break;case"b":this.calc=function(a,b){var c=this.snapToGrid(a,b,0);if(this.parameters.box.height+c[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).height(this.parameters.box.height+c[1])}};break;case"l":this.calc=function(a,b){var c=this.snapToGrid(a,b,1);if(this.parameters.box.width-c[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x+c[0],this.parameters.box.y).width(this.parameters.box.width-c[0])}};break;case"rot":this.calc=function(a,b){var c={x:a+this.parameters.p.x,y:b+this.parameters.p.y},d=Math.atan2(this.parameters.p.y-this.parameters.box.y-this.parameters.box.height/2,this.parameters.p.x-this.parameters.box.x-this.parameters.box.width/2),e=Math.atan2(c.y-this.parameters.box.y-this.parameters.box.height/2,c.x-this.parameters.box.x-this.parameters.box.width/2),f=180*(e-d)/Math.PI;this.el.center(this.parameters.box.cx,this.parameters.box.cy).rotate(this.parameters.rotation+f-f%this.options.snapToAngle,this.parameters.box.cx,this.parameters.box.cy)};break;case"point":this.calc=function(a,b){var c=this.snapToGrid(a,b,this.parameters.pointCoords[0],this.parameters.pointCoords[1]),d=this.el.array().valueOf();d[this.parameters.i][0]=this.parameters.pointCoords[0]+c[0],d[this.parameters.i][1]=this.parameters.pointCoords[1]+c[1],this.el.plot(d)}}this.el.fire("resizestart",{dx:this.parameters.x,dy:this.parameters.y,event:a}),SVG.on(window,"touchmove.resize",function(a){b.update(a||window.event)}),SVG.on(window,"touchend.resize",function(){b.done()}),SVG.on(window,"mousemove.resize",function(a){b.update(a||window.event)}),SVG.on(window,"mouseup.resize",function(){b.done()})},a.prototype.update=function(a){if(!a)return void(this.lastUpdateCall&&this.calc(this.lastUpdateCall[0],this.lastUpdateCall[1]));var b=this._extractPosition(a),c=this.transformPoint(b.x,b.y),d=c.x-this.parameters.p.x,e=c.y-this.parameters.p.y;this.lastUpdateCall=[d,e],this.calc(d,e),this.el.fire("resizing",{dx:d,dy:e,event:a})},a.prototype.done=function(){this.lastUpdateCall=null,SVG.off(window,"mousemove.resize"),SVG.off(window,"mouseup.resize"),SVG.off(window,"touchmove.resize"),SVG.off(window,"touchend.resize"),this.el.fire("resizedone")},a.prototype.snapToGrid=function(a,b,c,d){var e;return"undefined"!=typeof d?e=[(c+a)%this.options.snapToGrid,(d+b)%this.options.snapToGrid]:(c=null==c?3:c,e=[(this.parameters.box.x+a+(1&c?0:this.parameters.box.width))%this.options.snapToGrid,(this.parameters.box.y+b+(2&c?0:this.parameters.box.height))%this.options.snapToGrid]),a-=Math.abs(e[0])<this.options.snapToGrid/2?e[0]:e[0]-(0>a?-this.options.snapToGrid:this.options.snapToGrid),b-=Math.abs(e[1])<this.options.snapToGrid/2?e[1]:e[1]-(0>b?-this.options.snapToGrid:this.options.snapToGrid),this.constraintToBox(a,b,c,d)},a.prototype.constraintToBox=function(a,b,c,d){var e,f,g=this.options.constraint||{};return"undefined"!=typeof d?(e=c,f=d):(e=this.parameters.box.x+(1&c?0:this.parameters.box.width),f=this.parameters.box.y+(2&c?0:this.parameters.box.height)),"undefined"!=typeof g.minX&&e+a<g.minX&&(a=g.minX-e),"undefined"!=typeof g.maxX&&e+a>g.maxX&&(a=g.maxX-e),"undefined"!=typeof g.minY&&f+b<g.minY&&(b=g.minY-f),"undefined"!=typeof g.maxY&&f+b>g.maxY&&(b=g.maxY-f),[a,b]},SVG.extend(SVG.Element,{resize:function(b){return(this.remember("_resizeHandler")||new a(this)).init(b||{}),this}}),SVG.Element.prototype.resize.defaults={snapToAngle:.1,snapToGrid:1,constraint:{}}}).call(this);
/*! svg.resize.js v1.4.1 MIT*/;!function(){"use strict";(function(){function t(t){t.remember("_resizeHandler",this),this.el=t,this.parameters={},this.lastUpdateCall=null,this.p=t.doc().node.createSVGPoint()}t.prototype.transformPoint=function(t,e,i){return this.p.x=t-(this.offset.x-window.pageXOffset),this.p.y=e-(this.offset.y-window.pageYOffset),this.p.matrixTransform(i||this.m)},t.prototype._extractPosition=function(t){return{x:t.clientX||t.touches[0].pageX,y:t.clientY||t.touches[0].pageY}},t.prototype.init=function(t){var e=this;if(this.stop(),"stop"!==t){this.options={};for(var i in this.el.resize.defaults)this.options[i]=this.el.resize.defaults[i],void 0!==t[i]&&(this.options[i]=t[i]);this.el.on("lt.resize",function(t){e.resize(t||window.event)}),this.el.on("rt.resize",function(t){e.resize(t||window.event)}),this.el.on("rb.resize",function(t){e.resize(t||window.event)}),this.el.on("lb.resize",function(t){e.resize(t||window.event)}),this.el.on("t.resize",function(t){e.resize(t||window.event)}),this.el.on("r.resize",function(t){e.resize(t||window.event)}),this.el.on("b.resize",function(t){e.resize(t||window.event)}),this.el.on("l.resize",function(t){e.resize(t||window.event)}),this.el.on("rot.resize",function(t){e.resize(t||window.event)}),this.el.on("point.resize",function(t){e.resize(t||window.event)}),this.update()}},t.prototype.stop=function(){return this.el.off("lt.resize"),this.el.off("rt.resize"),this.el.off("rb.resize"),this.el.off("lb.resize"),this.el.off("t.resize"),this.el.off("r.resize"),this.el.off("b.resize"),this.el.off("l.resize"),this.el.off("rot.resize"),this.el.off("point.resize"),this},t.prototype.resize=function(t){var e=this;this.m=this.el.node.getScreenCTM().inverse(),this.offset={x:window.pageXOffset,y:window.pageYOffset};var i=this._extractPosition(t.detail.event);if(this.parameters={type:this.el.type,p:this.transformPoint(i.x,i.y),x:t.detail.x,y:t.detail.y,box:this.el.bbox(),rotation:this.el.transform().rotation},"text"===this.el.type&&(this.parameters.fontSize=this.el.attr()["font-size"]),void 0!==t.detail.i){var s=this.el.array().valueOf();this.parameters.i=t.detail.i,this.parameters.pointCoords=[s[t.detail.i][0],s[t.detail.i][1]]}switch(t.type){case"lt":this.calc=function(t,e){var i=this.snapToGrid(t,e);if(this.parameters.box.width-i[0]>0&&this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-i[0]);this.el.move(this.parameters.box.x+i[0],this.parameters.box.y+i[1]).size(this.parameters.box.width-i[0],this.parameters.box.height-i[1])}};break;case"rt":this.calc=function(t,e){var i=this.snapToGrid(t,e,2);if(this.parameters.box.width+i[0]>0&&this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+i[0]);this.el.move(this.parameters.box.x,this.parameters.box.y+i[1]).size(this.parameters.box.width+i[0],this.parameters.box.height-i[1])}};break;case"rb":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.width+i[0]>0&&this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+i[0]);this.el.move(this.parameters.box.x,this.parameters.box.y).size(this.parameters.box.width+i[0],this.parameters.box.height+i[1])}};break;case"lb":this.calc=function(t,e){var i=this.snapToGrid(t,e,1);if(this.parameters.box.width-i[0]>0&&this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-i[0]);this.el.move(this.parameters.box.x+i[0],this.parameters.box.y).size(this.parameters.box.width-i[0],this.parameters.box.height+i[1])}};break;case"t":this.calc=function(t,e){var i=this.snapToGrid(t,e,2);if(this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y+i[1]).height(this.parameters.box.height-i[1])}};break;case"r":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.width+i[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).width(this.parameters.box.width+i[0])}};break;case"b":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).height(this.parameters.box.height+i[1])}};break;case"l":this.calc=function(t,e){var i=this.snapToGrid(t,e,1);if(this.parameters.box.width-i[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x+i[0],this.parameters.box.y).width(this.parameters.box.width-i[0])}};break;case"rot":this.calc=function(t,e){var i={x:t+this.parameters.p.x,y:e+this.parameters.p.y},s=Math.atan2(this.parameters.p.y-this.parameters.box.y-this.parameters.box.height/2,this.parameters.p.x-this.parameters.box.x-this.parameters.box.width/2),r=Math.atan2(i.y-this.parameters.box.y-this.parameters.box.height/2,i.x-this.parameters.box.x-this.parameters.box.width/2),a=180*(r-s)/Math.PI;this.el.center(this.parameters.box.cx,this.parameters.box.cy).rotate(this.parameters.rotation+a-a%this.options.snapToAngle,this.parameters.box.cx,this.parameters.box.cy)};break;case"point":this.calc=function(t,e){var i=this.snapToGrid(t,e,this.parameters.pointCoords[0],this.parameters.pointCoords[1]),s=this.el.array().valueOf();s[this.parameters.i][0]=this.parameters.pointCoords[0]+i[0],s[this.parameters.i][1]=this.parameters.pointCoords[1]+i[1],this.el.plot(s)}}this.el.fire("resizestart",{dx:this.parameters.x,dy:this.parameters.y,event:t}),SVG.on(window,"touchmove.resize",function(t){e.update(t||window.event)}),SVG.on(window,"touchend.resize",function(){e.done()}),SVG.on(window,"mousemove.resize",function(t){e.update(t||window.event)}),SVG.on(window,"mouseup.resize",function(){e.done()})},t.prototype.update=function(t){if(!t)return void(this.lastUpdateCall&&this.calc(this.lastUpdateCall[0],this.lastUpdateCall[1]));var e=this._extractPosition(t),i=this.transformPoint(e.x,e.y),s=i.x-this.parameters.p.x,r=i.y-this.parameters.p.y;this.lastUpdateCall=[s,r],this.calc(s,r),this.el.fire("resizing",{dx:s,dy:r,event:t})},t.prototype.done=function(){this.lastUpdateCall=null,SVG.off(window,"mousemove.resize"),SVG.off(window,"mouseup.resize"),SVG.off(window,"touchmove.resize"),SVG.off(window,"touchend.resize"),this.el.fire("resizedone")},t.prototype.snapToGrid=function(t,e,i,s){var r;return void 0!==s?r=[(i+t)%this.options.snapToGrid,(s+e)%this.options.snapToGrid]:(i=null==i?3:i,r=[(this.parameters.box.x+t+(1&i?0:this.parameters.box.width))%this.options.snapToGrid,(this.parameters.box.y+e+(2&i?0:this.parameters.box.height))%this.options.snapToGrid]),t-=Math.abs(r[0])<this.options.snapToGrid/2?r[0]:r[0]-(t<0?-this.options.snapToGrid:this.options.snapToGrid),e-=Math.abs(r[1])<this.options.snapToGrid/2?r[1]:r[1]-(e<0?-this.options.snapToGrid:this.options.snapToGrid),this.constraintToBox(t,e,i,s)},t.prototype.constraintToBox=function(t,e,i,s){var r,a,o=this.options.constraint||{};return void 0!==s?(r=i,a=s):(r=this.parameters.box.x+(1&i?0:this.parameters.box.width),a=this.parameters.box.y+(2&i?0:this.parameters.box.height)),void 0!==o.minX&&r+t<o.minX&&(t=o.minX-r),void 0!==o.maxX&&r+t>o.maxX&&(t=o.maxX-r),void 0!==o.minY&&a+e<o.minY&&(e=o.minY-a),void 0!==o.maxY&&a+e>o.maxY&&(e=o.maxY-a),[t,e]},SVG.extend(SVG.Element,{resize:function(e){return(this.remember("_resizeHandler")||new t(this)).init(e||{}),this}}),SVG.Element.prototype.resize.defaults={snapToAngle:.1,snapToGrid:1,constraint:{}}}).call(this)}();

35

package.json
{
"name": "svg.resize.js",
"version": "1.4.0",
"description": "An extension for svn.js which allows to resize elements which are selected",
"version": "1.4.1",
"description": "An extension for svg.js which allows to resize elements which are selected",
"keywords": [

@@ -10,3 +10,3 @@ "svg.js",

],
"bugs": "https://github.com/Fuzzyma/svg.resize.js/issues",
"bugs": "https://github.com/svgdotjs/svg.resize.js/issues",
"license": "MIT",

@@ -19,3 +19,3 @@ "author": {

},
"homepage": "https://github.com/Fuzzyma/svg.resize.js",
"homepage": "https://github.com/svgdotjs/svg.resize.js",
"main": "dist/svg.resize.js",

@@ -25,5 +25,8 @@ "files": [

],
"scripts": {
"build": "gulp"
},
"repository": {
"type": "git",
"url": "https://github.com/Fuzzyma/svg.resize.js.git"
"url": "https://github.com/svgdotjs/svg.resize.js.git"
},

@@ -34,16 +37,16 @@ "engines": {

"devDependencies": {
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.4.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-cssmin": "^0.12.1",
"grunt-contrib-copy": "^0.7.0",
"grunt": "~0.4.5",
"grunt-bumper": "^1.0.4"
"del": "^2.2.2",
"gulp": "^3.9.1",
"gulp-header": "^1.8.8",
"gulp-iife": "^0.3.0",
"gulp-rename": "^1.2.2",
"gulp-standard": "^10.0.0",
"gulp-trimlines": "^1.0.1",
"gulp-uglify": "^2.1.2",
"gulp-wrap-iife": "0.0.1"
},
"dependencies": {
"svg.js":"^2.0.2",
"svg.select.js":"^1.0.4"
"svg.js": "^2.2.5",
"svg.select.js": "^2.1.2"
}
}
svg.resize.js
=============
An extension of [svg.js](https://github.com/wout/svg.js) which allows to resize elements which are selected with [svg.select.js](https://github.com/Fuzzyma/svg.select.js)
An extension of [svg.js](https://github.com/svgdotjs/svg.js) which allows to resize elements which are selected with [svg.select.js](https://github.com/svgdotjs/svg.select.js)
# Demo
For a demo see http://fuzzyma.github.io/svg.resize.js/
For a demo see http://svgdotjs.github.io/svg.resize.js/

@@ -10,0 +10,0 @@ # Get Started

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc