mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Added destroy lifecycle method
This commit is contained in:
@@ -20,6 +20,14 @@ class Clipboard extends Emitter {
|
|||||||
this.delegateClick(selector);
|
this.delegateClick(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {String} selector
|
||||||
|
* @param {Object} options
|
||||||
|
*/
|
||||||
|
destroy() {
|
||||||
|
this.undelegateClick();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines if attributes would be resolved using internal setter functions
|
* Defines if attributes would be resolved using internal setter functions
|
||||||
* or custom functions that were passed in the constructor.
|
* or custom functions that were passed in the constructor.
|
||||||
@@ -36,14 +44,22 @@ class Clipboard extends Emitter {
|
|||||||
* @param {String} selector
|
* @param {String} selector
|
||||||
*/
|
*/
|
||||||
delegateClick(selector) {
|
delegateClick(selector) {
|
||||||
Delegate.bind(document.body, selector, 'click', (e) => this.initialize(e));
|
Delegate.bind(document.body, selector, 'click', this.initialize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undelegates a click event on the passed selector.
|
||||||
|
* @param {String} selector
|
||||||
|
*/
|
||||||
|
undelegateClick() {
|
||||||
|
Delegate.unbind(document.body, 'click', this.initialize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a new `ClipboardAction` on each click event.
|
* Defines a new `ClipboardAction` on each click event.
|
||||||
* @param {Event} e
|
* @param {Event} e
|
||||||
*/
|
*/
|
||||||
initialize(e) {
|
initialize = (e) => {
|
||||||
if (this.clipboardAction) {
|
if (this.clipboardAction) {
|
||||||
this.clipboardAction = null;
|
this.clipboardAction = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user