Skip to content

Commit 8295ae5

Browse files
Christopher Leeagilgur5
authored andcommitted
(feat): add on API method to rebind event handlers
- does the opposite of `off` - replace internal usage with new `on` functionality as well
1 parent fe1cf7a commit 8295ae5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export default class SignatureCanvas extends Component {
3535
componentDidMount () {
3636
this._ctx = this._canvas.getContext("2d");
3737

38-
this._handleMouseEvents();
39-
this._handleTouchEvents();
38+
this.on()
4039
this._resizeCanvas();
4140
this.clear()
4241
}
@@ -142,6 +141,11 @@ export default class SignatureCanvas extends Component {
142141
document.addEventListener('touchend', this._handleTouchEnd)
143142
}
144143

144+
on = () => {
145+
this._handleMouseEvents()
146+
this._handleTouchEvents()
147+
}
148+
145149
off = () => {
146150
this._canvas.removeEventListener('mousedown', this._handleMouseDown)
147151
this._canvas.removeEventListener('mousemove', this._handleMouseMove)

0 commit comments

Comments
 (0)