signature_pad
Advanced tools
Comparing version 1.5.2 to 1.5.3
@@ -0,1 +1,34 @@ | ||
(function (root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. Register as an anonymous module unless amdModuleId is set | ||
define([], function () { | ||
return (root['SignaturePad'] = factory()); | ||
}); | ||
} else if (typeof exports === 'object') { | ||
// Node. Does not work with strict CommonJS, but | ||
// only CommonJS-like environments that support module.exports, | ||
// like Node. | ||
module.exports = factory(); | ||
} else { | ||
root['SignaturePad'] = factory(); | ||
} | ||
}(this, function () { | ||
/*! | ||
* Signature Pad v1.5.3 | ||
* https://github.com/szimek/signature_pad | ||
* | ||
* Copyright 2016 Szymon Nowak | ||
* Released under the MIT license | ||
* | ||
* The main idea and some parts of the code (e.g. drawing variable width Bézier curve) are taken from: | ||
* http://corner.squareup.com/2012/07/smoother-signatures.html | ||
* | ||
* Implementation of interpolation using cubic Bézier curves is taken from: | ||
* http://benknowscode.wordpress.com/2012/09/14/path-interpolation-using-cubic-bezier-and-control-point-estimation-in-javascript | ||
* | ||
* Algorithm for approximated length of a Bézier curve is taken from: | ||
* http://www.lemoda.net/maths/bezier-length/index.html | ||
* | ||
*/ | ||
var SignaturePad = (function (document) { | ||
@@ -146,8 +179,9 @@ "use strict"; | ||
SignaturePad.prototype._handleTouchEvents = function () { | ||
// Pass touch events to canvas element on mobile IE. | ||
// Pass touch events to canvas element on mobile IE11 and Edge. | ||
this._canvas.style.msTouchAction = 'none'; | ||
this._canvas.style.touchAction = 'none'; | ||
this._canvas.addEventListener("touchstart", this._handleTouchStart); | ||
this._canvas.addEventListener("touchmove", this._handleTouchMove); | ||
document.addEventListener("touchend", this._handleTouchEnd); | ||
this._canvas.addEventListener("touchend", this._handleTouchEnd); | ||
}; | ||
@@ -167,3 +201,3 @@ | ||
this._canvas.removeEventListener("touchmove", this._handleTouchMove); | ||
document.removeEventListener("touchend", this._handleTouchEnd); | ||
this._canvas.removeEventListener("touchend", this._handleTouchEnd); | ||
}; | ||
@@ -354,1 +388,5 @@ | ||
})(document); | ||
return SignaturePad; | ||
})); |
{ | ||
"name": "signature_pad", | ||
"description": "Library for drawing smooth signatures.", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"homepage": "https://github.com/szimek/signature_pad", | ||
@@ -12,3 +12,5 @@ "author": { | ||
"main": "./signature_pad.js", | ||
"scripts": { | ||
"build": "grunt" | ||
}, | ||
"repository" : { | ||
@@ -15,0 +17,0 @@ "type" : "git", |
@@ -26,4 +26,5 @@ Signature Pad [![Code Climate](https://codeclimate.com/github/szimek/signature_pad.png)](https://codeclimate.com/github/szimek/signature_pad) | ||
// Returns signature image as data URL | ||
signaturePad.toDataURL(); | ||
// Returns signature image as data URL (see https://mdn.io/todataurl for the list of possible paramters) | ||
signaturePad.toDataURL(); // save image as PNG | ||
signaturePad.toDataURL("image/jpeg"); // save image as JPEG | ||
@@ -83,3 +84,24 @@ // Draws signature image from data URL | ||
### Handling data URI encoded images on the server side | ||
### Tips and tricks | ||
#### Handling high DPI screens | ||
To correctly handle canvas on low and high DPI screens one has to take `devicePixelRatio` into account and scale the canvas accordingly. This scaling is also necessary to properly display signatures loaded via `SignaturePad#fromDataURL`. Here's an example how it can be done: | ||
```javascript | ||
function resizeCanvas() { | ||
var ratio = Math.max(window.devicePixelRatio || 1, 1); | ||
canvas.width = canvas.offsetWidth * ratio; | ||
canvas.height = canvas.offsetHeight * ratio; | ||
canvas.getContext("2d").scale(ratio, ratio); | ||
signaturePad.clear(); // otherwise isEmpty() might return incorrect value | ||
} | ||
window.addEventListener("resize", resizeCanvas); | ||
resizeCanvas(); | ||
``` | ||
Instead of `resize` event you can listen to screen orientation change, if you're using this library only on mobile devices. You can also throttle the `resize` event - you can find some examples on [this MDN page](https://developer.mozilla.org/en-US/docs/Web/Events/resize). | ||
When you modify width or height of a canvas, it will be automatically cleared by the browser. SignaturePad doesn't know about it by itself, so you can call `signaturePad.clear()` to make sure that `signaturePad.isEmpty()` returns correct value in this case. | ||
This clearing of the canvas by the browser can be annoying, especially on mobile devices e.g. when screen orientation is changed. There are a few workarounds though, e.g. you can [lock screen orientation](https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation), or read an image from the canvas before resizing it and write the image back after. | ||
#### Handling data URI encoded images on the server side | ||
If you are not familiar with data URI scheme, you can read more about it on [Wikipedia](http://en.wikipedia.org/wiki/Data_URI_scheme). | ||
@@ -108,65 +130,16 @@ | ||
And an example in PHP: | ||
Here's an example in PHP: | ||
``` php | ||
$data_uri = "data:image/png;base64,iVBORw0K..." | ||
$data_uri = "data:image/png;base64,iVBORw0K..."; | ||
$data_pieces = explode(",", $data_uri); | ||
$encoded_image = $data_pieces[1]; | ||
$decoded_image = base64_decode($encoded_image) | ||
$decoded_image = base64_decode($encoded_image); | ||
file_put_contents( "signature.png",$decoded_image); | ||
``` | ||
## Changelog | ||
### 1.5.2 | ||
* Prevent loading an empty string in `fromDataURL`. (#108) [Remo](https://github.com/Remo) | ||
* Reject points generated by resting hand (better handling of multi touch). (#48 and #57) [jurreantonisse](https://github.com/jurreantonisse) | ||
### Removing empty space around a signature | ||
If you'd like to remove (trim) empty space around a signature, you can do it on the server side or the client side. On the server side you can use e.g. ImageMagic and its `trim` option: `convert -trim input.jpg output.jpg`. If you don't have access to the server, or just want to trim the image before submitting it to the server, you can do it on the client side as well. Here's an example: https://github.com/szimek/signature_pad/issues/49#issue-29108215. | ||
### 1.5.1 | ||
* Prevent duplicate events on tap in iOS Safari. [PerfectPixel](https://github.com/PerfectPixel) | ||
### 1.5.0 | ||
* Add `on` method that rebinds all event handlers. [Alplob](https://github.com/Alplob) | ||
### 1.4.0 | ||
* Add `off` method that unbinds all event handlers. [Rob-ot](https://github.com/Rob-ot) | ||
### 1.3.6 | ||
* Fix support for Browserify. [chevett](https://github.com/chevett) | ||
### 1.3.5 | ||
* Add support for CommonJS/AMD/UMD. | ||
### 1.3.4 | ||
* Really fix `fromDataURL` on HiDPI screens. | ||
### 1.3.3 | ||
* Fix `fromDataURL` on HiDPI screens. | ||
### 1.3.2 | ||
* Fix `onBegin` and `onEnd` callbacks when passed as options to constructor. [yinsee](https://github.com/yinsee) | ||
### 1.3.1 | ||
* Fix handling touch events on mobile IE. [tocsoft](https://github.com/tocsoft) | ||
### 1.3.0 | ||
* Add `onBegin` and `onEnd` callbacks. [rogerz](https://github.com/rogerz) | ||
### 1.2.4 | ||
* Fix bug where stroke becomes very thin. [mvirkkunen](https://github.com/mvirkkunen) | ||
### 1.2.3 | ||
* Fix `SignaturePad#fromDataURL` on Firefox. [Fr3nzzy](https://github.com/Fr3nzzy) | ||
### 1.2.2 | ||
* Make `SignaturePad#isEmpty` return false after loading an image using `SignaturePad#fromDataURL`. [krisivanov](https://github.com/krisivanov) | ||
### 1.2.1 | ||
* Fixed `SignaturePad#clear()`. | ||
### 1.2.0 | ||
* Add `backgroundColor` option to set custom color of the background on `SignaturePad#clear()`. | ||
* Rename `color` option to `penColor`. | ||
* Fix passing arguments to canvas element on `SignaturePad#toDataURL()`. | ||
## License | ||
Released under the [MIT License](http://www.opensource.org/licenses/MIT). |
@@ -18,6 +18,6 @@ (function (root, factory) { | ||
/*! | ||
* Signature Pad v1.5.2 | ||
* Signature Pad v1.5.3 | ||
* https://github.com/szimek/signature_pad | ||
* | ||
* Copyright 2015 Szymon Nowak | ||
* Copyright 2016 Szymon Nowak | ||
* Released under the MIT license | ||
@@ -180,8 +180,9 @@ * | ||
SignaturePad.prototype._handleTouchEvents = function () { | ||
// Pass touch events to canvas element on mobile IE. | ||
// Pass touch events to canvas element on mobile IE11 and Edge. | ||
this._canvas.style.msTouchAction = 'none'; | ||
this._canvas.style.touchAction = 'none'; | ||
this._canvas.addEventListener("touchstart", this._handleTouchStart); | ||
this._canvas.addEventListener("touchmove", this._handleTouchMove); | ||
document.addEventListener("touchend", this._handleTouchEnd); | ||
this._canvas.addEventListener("touchend", this._handleTouchEnd); | ||
}; | ||
@@ -201,3 +202,3 @@ | ||
this._canvas.removeEventListener("touchmove", this._handleTouchMove); | ||
document.removeEventListener("touchend", this._handleTouchEnd); | ||
this._canvas.removeEventListener("touchend", this._handleTouchEnd); | ||
}; | ||
@@ -204,0 +205,0 @@ |
!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.SignaturePad=b()}):"object"==typeof exports?module.exports=b():a.SignaturePad=b()}(this,function(){/*! | ||
* Signature Pad v1.5.2 | https://github.com/szimek/signature_pad | ||
* (c) 2015 Szymon Nowak | Released under the MIT license | ||
* Signature Pad v1.5.3 | https://github.com/szimek/signature_pad | ||
* (c) 2016 Szymon Nowak | Released under the MIT license | ||
*/ | ||
var a=function(a){"use strict";var b=function(a,b){var c=this,d=b||{};this.velocityFilterWeight=d.velocityFilterWeight||.7,this.minWidth=d.minWidth||.5,this.maxWidth=d.maxWidth||2.5,this.dotSize=d.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=d.penColor||"black",this.backgroundColor=d.backgroundColor||"rgba(0,0,0,0)",this.onEnd=d.onEnd,this.onBegin=d.onBegin,this._canvas=a,this._ctx=a.getContext("2d"),this.clear(),this._handleMouseDown=function(a){1===a.which&&(c._mouseButtonDown=!0,c._strokeBegin(a))},this._handleMouseMove=function(a){c._mouseButtonDown&&c._strokeUpdate(a)},this._handleMouseUp=function(a){1===a.which&&c._mouseButtonDown&&(c._mouseButtonDown=!1,c._strokeEnd(a))},this._handleTouchStart=function(a){if(1==a.targetTouches.length){var b=a.changedTouches[0];c._strokeBegin(b)}},this._handleTouchMove=function(a){a.preventDefault();var b=a.targetTouches[0];c._strokeUpdate(b)},this._handleTouchEnd=function(a){var b=a.target===c._canvas;b&&(a.preventDefault(),c._strokeEnd(a))},this._handleMouseEvents(),this._handleTouchEvents()};b.prototype.clear=function(){var a=this._ctx,b=this._canvas;a.fillStyle=this.backgroundColor,a.clearRect(0,0,b.width,b.height),a.fillRect(0,0,b.width,b.height),this._reset()},b.prototype.toDataURL=function(){var a=this._canvas;return a.toDataURL.apply(a,arguments)},b.prototype.fromDataURL=function(a){var b=this,c=new Image,d=window.devicePixelRatio||1,e=this._canvas.width/d,f=this._canvas.height/d;this._reset(),c.src=a,c.onload=function(){b._ctx.drawImage(c,0,0,e,f)},this._isEmpty=!1},b.prototype._strokeUpdate=function(a){var b=this._createPoint(a);this._addPoint(b)},b.prototype._strokeBegin=function(a){this._reset(),this._strokeUpdate(a),"function"==typeof this.onBegin&&this.onBegin(a)},b.prototype._strokeDraw=function(a){var b=this._ctx,c="function"==typeof this.dotSize?this.dotSize():this.dotSize;b.beginPath(),this._drawPoint(a.x,a.y,c),b.closePath(),b.fill()},b.prototype._strokeEnd=function(a){var b=this.points.length>2,c=this.points[0];!b&&c&&this._strokeDraw(c),"function"==typeof this.onEnd&&this.onEnd(a)},b.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),a.addEventListener("mouseup",this._handleMouseUp)},b.prototype._handleTouchEvents=function(){this._canvas.style.msTouchAction="none",this._canvas.addEventListener("touchstart",this._handleTouchStart),this._canvas.addEventListener("touchmove",this._handleTouchMove),a.addEventListener("touchend",this._handleTouchEnd)},b.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},b.prototype.off=function(){this._canvas.removeEventListener("mousedown",this._handleMouseDown),this._canvas.removeEventListener("mousemove",this._handleMouseMove),a.removeEventListener("mouseup",this._handleMouseUp),this._canvas.removeEventListener("touchstart",this._handleTouchStart),this._canvas.removeEventListener("touchmove",this._handleTouchMove),a.removeEventListener("touchend",this._handleTouchEnd)},b.prototype.isEmpty=function(){return this._isEmpty},b.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._isEmpty=!0,this._ctx.fillStyle=this.penColor},b.prototype._createPoint=function(a){var b=this._canvas.getBoundingClientRect();return new c(a.clientX-b.left,a.clientY-b.top)},b.prototype._addPoint=function(a){var b,c,e,f,g=this.points;g.push(a),g.length>2&&(3===g.length&&g.unshift(g[0]),f=this._calculateCurveControlPoints(g[0],g[1],g[2]),b=f.c2,f=this._calculateCurveControlPoints(g[1],g[2],g[3]),c=f.c1,e=new d(g[1],b,c,g[2]),this._addCurve(e),g.shift())},b.prototype._calculateCurveControlPoints=function(a,b,d){var e=a.x-b.x,f=a.y-b.y,g=b.x-d.x,h=b.y-d.y,i={x:(a.x+b.x)/2,y:(a.y+b.y)/2},j={x:(b.x+d.x)/2,y:(b.y+d.y)/2},k=Math.sqrt(e*e+f*f),l=Math.sqrt(g*g+h*h),m=i.x-j.x,n=i.y-j.y,o=l/(k+l),p={x:j.x+m*o,y:j.y+n*o},q=b.x-p.x,r=b.y-p.y;return{c1:new c(i.x+q,i.y+r),c2:new c(j.x+q,j.y+r)}},b.prototype._addCurve=function(a){var b,c,d=a.startPoint,e=a.endPoint;b=e.velocityFrom(d),b=this.velocityFilterWeight*b+(1-this.velocityFilterWeight)*this._lastVelocity,c=this._strokeWidth(b),this._drawCurve(a,this._lastWidth,c),this._lastVelocity=b,this._lastWidth=c},b.prototype._drawPoint=function(a,b,c){var d=this._ctx;d.moveTo(a,b),d.arc(a,b,c,0,2*Math.PI,!1),this._isEmpty=!1},b.prototype._drawCurve=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o=this._ctx,p=c-b;for(d=Math.floor(a.length()),o.beginPath(),f=0;d>f;f++)g=f/d,h=g*g,i=h*g,j=1-g,k=j*j,l=k*j,m=l*a.startPoint.x,m+=3*k*g*a.control1.x,m+=3*j*h*a.control2.x,m+=i*a.endPoint.x,n=l*a.startPoint.y,n+=3*k*g*a.control1.y,n+=3*j*h*a.control2.y,n+=i*a.endPoint.y,e=b+i*p,this._drawPoint(m,n,e);o.closePath(),o.fill()},b.prototype._strokeWidth=function(a){return Math.max(this.maxWidth/(a+1),this.minWidth)};var c=function(a,b,c){this.x=a,this.y=b,this.time=c||(new Date).getTime()};c.prototype.velocityFrom=function(a){return this.time!==a.time?this.distanceTo(a)/(this.time-a.time):1},c.prototype.distanceTo=function(a){return Math.sqrt(Math.pow(this.x-a.x,2)+Math.pow(this.y-a.y,2))};var d=function(a,b,c,d){this.startPoint=a,this.control1=b,this.control2=c,this.endPoint=d};return d.prototype.length=function(){var a,b,c,d,e,f,g,h,i=10,j=0;for(a=0;i>=a;a++)b=a/i,c=this._point(b,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),d=this._point(b,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y),a>0&&(g=c-e,h=d-f,j+=Math.sqrt(g*g+h*h)),e=c,f=d;return j},d.prototype._point=function(a,b,c,d,e){return b*(1-a)*(1-a)*(1-a)+3*c*(1-a)*(1-a)*a+3*d*(1-a)*a*a+e*a*a*a},b}(document);return a}); | ||
var a=function(a){"use strict";var b=function(a,b){var c=this,d=b||{};this.velocityFilterWeight=d.velocityFilterWeight||.7,this.minWidth=d.minWidth||.5,this.maxWidth=d.maxWidth||2.5,this.dotSize=d.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=d.penColor||"black",this.backgroundColor=d.backgroundColor||"rgba(0,0,0,0)",this.onEnd=d.onEnd,this.onBegin=d.onBegin,this._canvas=a,this._ctx=a.getContext("2d"),this.clear(),this._handleMouseDown=function(a){1===a.which&&(c._mouseButtonDown=!0,c._strokeBegin(a))},this._handleMouseMove=function(a){c._mouseButtonDown&&c._strokeUpdate(a)},this._handleMouseUp=function(a){1===a.which&&c._mouseButtonDown&&(c._mouseButtonDown=!1,c._strokeEnd(a))},this._handleTouchStart=function(a){if(1==a.targetTouches.length){var b=a.changedTouches[0];c._strokeBegin(b)}},this._handleTouchMove=function(a){a.preventDefault();var b=a.targetTouches[0];c._strokeUpdate(b)},this._handleTouchEnd=function(a){var b=a.target===c._canvas;b&&(a.preventDefault(),c._strokeEnd(a))},this._handleMouseEvents(),this._handleTouchEvents()};b.prototype.clear=function(){var a=this._ctx,b=this._canvas;a.fillStyle=this.backgroundColor,a.clearRect(0,0,b.width,b.height),a.fillRect(0,0,b.width,b.height),this._reset()},b.prototype.toDataURL=function(){var a=this._canvas;return a.toDataURL.apply(a,arguments)},b.prototype.fromDataURL=function(a){var b=this,c=new Image,d=window.devicePixelRatio||1,e=this._canvas.width/d,f=this._canvas.height/d;this._reset(),c.src=a,c.onload=function(){b._ctx.drawImage(c,0,0,e,f)},this._isEmpty=!1},b.prototype._strokeUpdate=function(a){var b=this._createPoint(a);this._addPoint(b)},b.prototype._strokeBegin=function(a){this._reset(),this._strokeUpdate(a),"function"==typeof this.onBegin&&this.onBegin(a)},b.prototype._strokeDraw=function(a){var b=this._ctx,c="function"==typeof this.dotSize?this.dotSize():this.dotSize;b.beginPath(),this._drawPoint(a.x,a.y,c),b.closePath(),b.fill()},b.prototype._strokeEnd=function(a){var b=this.points.length>2,c=this.points[0];!b&&c&&this._strokeDraw(c),"function"==typeof this.onEnd&&this.onEnd(a)},b.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),a.addEventListener("mouseup",this._handleMouseUp)},b.prototype._handleTouchEvents=function(){this._canvas.style.msTouchAction="none",this._canvas.style.touchAction="none",this._canvas.addEventListener("touchstart",this._handleTouchStart),this._canvas.addEventListener("touchmove",this._handleTouchMove),this._canvas.addEventListener("touchend",this._handleTouchEnd)},b.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},b.prototype.off=function(){this._canvas.removeEventListener("mousedown",this._handleMouseDown),this._canvas.removeEventListener("mousemove",this._handleMouseMove),a.removeEventListener("mouseup",this._handleMouseUp),this._canvas.removeEventListener("touchstart",this._handleTouchStart),this._canvas.removeEventListener("touchmove",this._handleTouchMove),this._canvas.removeEventListener("touchend",this._handleTouchEnd)},b.prototype.isEmpty=function(){return this._isEmpty},b.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._isEmpty=!0,this._ctx.fillStyle=this.penColor},b.prototype._createPoint=function(a){var b=this._canvas.getBoundingClientRect();return new c(a.clientX-b.left,a.clientY-b.top)},b.prototype._addPoint=function(a){var b,c,e,f,g=this.points;g.push(a),g.length>2&&(3===g.length&&g.unshift(g[0]),f=this._calculateCurveControlPoints(g[0],g[1],g[2]),b=f.c2,f=this._calculateCurveControlPoints(g[1],g[2],g[3]),c=f.c1,e=new d(g[1],b,c,g[2]),this._addCurve(e),g.shift())},b.prototype._calculateCurveControlPoints=function(a,b,d){var e=a.x-b.x,f=a.y-b.y,g=b.x-d.x,h=b.y-d.y,i={x:(a.x+b.x)/2,y:(a.y+b.y)/2},j={x:(b.x+d.x)/2,y:(b.y+d.y)/2},k=Math.sqrt(e*e+f*f),l=Math.sqrt(g*g+h*h),m=i.x-j.x,n=i.y-j.y,o=l/(k+l),p={x:j.x+m*o,y:j.y+n*o},q=b.x-p.x,r=b.y-p.y;return{c1:new c(i.x+q,i.y+r),c2:new c(j.x+q,j.y+r)}},b.prototype._addCurve=function(a){var b,c,d=a.startPoint,e=a.endPoint;b=e.velocityFrom(d),b=this.velocityFilterWeight*b+(1-this.velocityFilterWeight)*this._lastVelocity,c=this._strokeWidth(b),this._drawCurve(a,this._lastWidth,c),this._lastVelocity=b,this._lastWidth=c},b.prototype._drawPoint=function(a,b,c){var d=this._ctx;d.moveTo(a,b),d.arc(a,b,c,0,2*Math.PI,!1),this._isEmpty=!1},b.prototype._drawCurve=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o=this._ctx,p=c-b;for(d=Math.floor(a.length()),o.beginPath(),f=0;d>f;f++)g=f/d,h=g*g,i=h*g,j=1-g,k=j*j,l=k*j,m=l*a.startPoint.x,m+=3*k*g*a.control1.x,m+=3*j*h*a.control2.x,m+=i*a.endPoint.x,n=l*a.startPoint.y,n+=3*k*g*a.control1.y,n+=3*j*h*a.control2.y,n+=i*a.endPoint.y,e=b+i*p,this._drawPoint(m,n,e);o.closePath(),o.fill()},b.prototype._strokeWidth=function(a){return Math.max(this.maxWidth/(a+1),this.minWidth)};var c=function(a,b,c){this.x=a,this.y=b,this.time=c||(new Date).getTime()};c.prototype.velocityFrom=function(a){return this.time!==a.time?this.distanceTo(a)/(this.time-a.time):1},c.prototype.distanceTo=function(a){return Math.sqrt(Math.pow(this.x-a.x,2)+Math.pow(this.y-a.y,2))};var d=function(a,b,c,d){this.startPoint=a,this.control1=b,this.control2=c,this.endPoint=d};return d.prototype.length=function(){var a,b,c,d,e,f,g,h,i=10,j=0;for(a=0;i>=a;a++)b=a/i,c=this._point(b,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),d=this._point(b,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y),a>0&&(g=c-e,h=d-f,j+=Math.sqrt(g*g+h*h)),e=c,f=d;return j},d.prototype._point=function(a,b,c,d,e){return b*(1-a)*(1-a)*(1-a)+3*c*(1-a)*(1-a)*a+3*d*(1-a)*a*a+e*a*a*a},b}(document);return a}); |
@@ -146,8 +146,9 @@ var SignaturePad = (function (document) { | ||
SignaturePad.prototype._handleTouchEvents = function () { | ||
// Pass touch events to canvas element on mobile IE. | ||
// Pass touch events to canvas element on mobile IE11 and Edge. | ||
this._canvas.style.msTouchAction = 'none'; | ||
this._canvas.style.touchAction = 'none'; | ||
this._canvas.addEventListener("touchstart", this._handleTouchStart); | ||
this._canvas.addEventListener("touchmove", this._handleTouchMove); | ||
document.addEventListener("touchend", this._handleTouchEnd); | ||
this._canvas.addEventListener("touchend", this._handleTouchEnd); | ||
}; | ||
@@ -167,3 +168,3 @@ | ||
this._canvas.removeEventListener("touchmove", this._handleTouchMove); | ||
document.removeEventListener("touchend", this._handleTouchEnd); | ||
this._canvas.removeEventListener("touchend", this._handleTouchEnd); | ||
}; | ||
@@ -170,0 +171,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74056
16
1256
143