Browse Source

Avoid errors in Resizer if the component is removed. Closes #4333

pull/4343/head
Artur Arseniev 4 years ago
parent
commit
5f2b3a03ed
  1. 22
      src/utils/Resizer.js

22
src/utils/Resizer.js

@ -287,11 +287,12 @@ class Resizer {
}; };
// Listen events // Listen events
var doc = this.getDocumentEl(); const docs = this.getDocumentEl();
on(doc, 'mousemove', this.move); this.docs = docs;
on(doc, 'keydown', this.handleKeyDown); on(docs, 'mousemove', this.move);
on(doc, 'mouseup', this.stop); on(docs, 'keydown', this.handleKeyDown);
isFunction(this.onStart) && this.onStart(e, { docs: doc, config, el, resizer }); on(docs, 'mouseup', this.stop);
isFunction(this.onStart) && this.onStart(e, { docs, config, el, resizer });
this.toggleFrames(1); this.toggleFrames(1);
this.move(e); this.move(e);
} }
@ -339,13 +340,14 @@ class Resizer {
*/ */
stop(e) { stop(e) {
const config = this.opts; const config = this.opts;
var doc = this.getDocumentEl(); const docs = this.docs || this.getDocumentEl();
off(doc, 'mousemove', this.move); off(docs, 'mousemove', this.move);
off(doc, 'keydown', this.handleKeyDown); off(docs, 'keydown', this.handleKeyDown);
off(doc, 'mouseup', this.stop); off(docs, 'mouseup', this.stop);
this.updateRect(1); this.updateRect(1);
this.toggleFrames(); this.toggleFrames();
isFunction(this.onEnd) && this.onEnd(e, { docs: doc, config }); isFunction(this.onEnd) && this.onEnd(e, { docs, config });
delete this.docs;
} }
/** /**

Loading…
Cancel
Save