forked from wallabag/wallabag
Extract Materialize Sidenav controller
This commit is contained in:
24
assets/controllers/materialize/sidenav_controller.js
Normal file
24
assets/controllers/materialize/sidenav_controller.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
import M from '@materializecss/materialize';
|
||||
|
||||
const mobileMaxWidth = 993;
|
||||
|
||||
export default class extends Controller {
|
||||
static values = {
|
||||
edge: { type: String, default: 'left' },
|
||||
};
|
||||
|
||||
connect() {
|
||||
this.instance = M.Sidenav.init(this.element, { edge: this.edgeValue });
|
||||
}
|
||||
|
||||
close() {
|
||||
if (window.innerWidth < mobileMaxWidth) {
|
||||
this.instance.close();
|
||||
}
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
this.instance.destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user