https://github.com/polydile/dile-close-document-click-mixin
Mixin to close custom elements when user do clicks in any document area.
https://github.com/polydile/dile-close-document-click-mixin
Last synced: over 1 year ago
JSON representation
Mixin to close custom elements when user do clicks in any document area.
- Host: GitHub
- URL: https://github.com/polydile/dile-close-document-click-mixin
- Owner: Polydile
- License: mit
- Created: 2019-08-02T17:18:32.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-08T17:56:54.000Z (almost 6 years ago)
- Last Synced: 2024-04-24T22:42:53.188Z (about 2 years ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Moved
**This package has moved** and is now available at [@dile/ui](https://github.com/Polydile/dile-components). Please update your dependencies. This repository is no longer maintained. You can read the documentation at [Dile Components](https://dile-components.com/).
# DileCloseDocumentClickMixin
Mixin to close custom elements when user do click in any area of the document.
This mixin, that you may apply to any Custom Element, offers a way to close elements when the user clicks in any area of the document.
## Usage
Install it:
```bash
npm i dile-close-document-click-mixin
```
To use it you olny need to extend your custom element class with the mixin.
```javascript
import { DileCloseDocumentClickMixin } from 'dile-close-document-click-mixin/dile-close-document-click-mixin.js';
class MyElement extends DileCloseDocumentClickMixin(HTMLElement) {
// your custom element code...
}
```
To do it's work, the mixin depends on a close() method created in your custom element class.
## Available methods
The mixin also provides two utility methods:
- **closeAll()**: Close all the elements of this type
- **closeOthers()**: Close the other items of this type (distinct to this)