Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add destroy method API #347

Closed
xuexb opened this issue Nov 22, 2022 · 1 comment
Closed

Add destroy method API #347

xuexb opened this issue Nov 22, 2022 · 1 comment

Comments

@xuexb
Copy link

xuexb commented Nov 22, 2022

In some scenarios, we may need to actively destroy Driver instances, and these events should also be unregistered.

driver.js/src/index.js

Lines 86 to 103 in 4a0247e

/**
* Binds any DOM events listeners
* @todo: add throttling in all the listeners
* @private
*/
bind() {
this.window.addEventListener('resize', this.onResize, false);
this.window.addEventListener('keyup', this.onKeyUp, false);
// Binding both touch and click results in popup getting shown and then immediately get hidden.
// Adding the check to not bind the click event if the touch is supported i.e. on mobile devices
// Issue: https://github.com/kamranahmedse/driver.js/issues/150
if (!('ontouchstart' in document.documentElement)) {
this.window.addEventListener('click', this.onClick, false);
} else {
this.window.addEventListener('touchstart', this.onClick, false);
}
}

@kamranahmedse
Copy link
Owner

We just released v1.0 of driver.js which has been rewritten from the ground up. We do have a destroy method. Please have a look at the docs and do let me know if you face any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants