From 222bf87120b2203516d456f4cb1103e7e577f37f Mon Sep 17 00:00:00 2001
From: Alplob
Date: Fri, 4 Sep 2015 18:31:56 +0800
Subject: [PATCH 1/2] Add an .on() method to re-bind event
Add an .on() method to re-bind event after the method .off() had been called.
---
example/js/signature_pad.js | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/example/js/signature_pad.js b/example/js/signature_pad.js
index dac9a26c..45bdce39 100644
--- a/example/js/signature_pad.js
+++ b/example/js/signature_pad.js
@@ -184,6 +184,17 @@ var SignaturePad = (function (document) {
document.addEventListener("touchend", this._handleTouchEnd);
};
+ SignaturePad.prototype.on = function () {
+ document.addEventListener("mouseup", this._handleMouseUp);
+ this._canvas.addEventListener("mousedown", this._handleMouseDown);
+ this._canvas.addEventListener("mousemove", this._handleMouseMove);
+
+ document.addEventListener("touchend", this._handleTouchEnd);
+ this._canvas.addEventListener("touchstart", this._handleTouchStart);
+ this._canvas.addEventListener("touchmove", this._handleTouchMove);
+ };
+
+
SignaturePad.prototype.off = function () {
this._canvas.removeEventListener("mousedown", this._handleMouseDown);
this._canvas.removeEventListener("mousemove", this._handleMouseMove);
From 073110f57740f7240913850186edf21f7b41b2aa Mon Sep 17 00:00:00 2001
From: Alplob
Date: Sat, 5 Sep 2015 14:02:35 +0800
Subject: [PATCH 2/2] Update signature_pad.js
---
example/js/signature_pad.js | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/example/js/signature_pad.js b/example/js/signature_pad.js
index 45bdce39..dfd95c0f 100644
--- a/example/js/signature_pad.js
+++ b/example/js/signature_pad.js
@@ -185,16 +185,10 @@ var SignaturePad = (function (document) {
};
SignaturePad.prototype.on = function () {
- document.addEventListener("mouseup", this._handleMouseUp);
- this._canvas.addEventListener("mousedown", this._handleMouseDown);
- this._canvas.addEventListener("mousemove", this._handleMouseMove);
-
- document.addEventListener("touchend", this._handleTouchEnd);
- this._canvas.addEventListener("touchstart", this._handleTouchStart);
- this._canvas.addEventListener("touchmove", this._handleTouchMove);
+ this._handleMouseEvents();
+ this._handleTouchEvents();
};
-
SignaturePad.prototype.off = function () {
this._canvas.removeEventListener("mousedown", this._handleMouseDown);
this._canvas.removeEventListener("mousemove", this._handleMouseMove);