Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onokumus/mmbase
Base class for metismenu
https://github.com/onokumus/mmbase
Last synced: about 2 months ago
JSON representation
Base class for metismenu
- Host: GitHub
- URL: https://github.com/onokumus/mmbase
- Owner: onokumus
- License: gpl-3.0
- Created: 2022-06-21T20:01:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-26T15:00:38.000Z (over 2 years ago)
- Last Synced: 2024-10-12T06:47:22.710Z (3 months ago)
- Language: TypeScript
- Homepage: https://onokumus.github.io/mmbase
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# mmbase
> Base class for metismenu.## Install
```sh
npm install mmbase
```## Usage
```js
import MMBase from 'mmbase';const selected = document.querySelector('.my-target');
// create new MMBase instance
const mmb = new MMBase(selected);// create handler function
const myHandler = (evt) => {
console.log(evt.detail);
}
```
### Extend```js
import MMBase from 'mmbase';class MyClass extends MMBase {}
```#### Properties
`MMBase` provides the following "private" property to subclasses:
| property | description |
| --- | --- |
| `root` | The root element passed into the constructor as the first argument. |#### Methods
`MMBase` provides the following methods to subclasses:
| method | description |
| --- | --- |
| `on(evt: string, handler: EventListener)` | Adds an event listener to the root element for the given `evt`. Note that this is simply a proxy to `this.root.addEventListener`. |
| `off(evt: string, handler: EventListener)` | Removes an event listener from the root element. Note that this is simply a proxy to `this.root.removeEventListener`. |
| `emit(evt: string, evtData: Object, shouldBubble: boolean = false)` | Dispatches a custom event of type `evt` with detail `evtData` from the root element. It also takes an optional shouldBubble argument to specify if the event should bubble. |