1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-01 17:38:38 +00:00

Extract Materialize FAB controller

This commit is contained in:
Yassine Guedidi 2025-03-02 12:32:11 +01:00
parent a7a4c5fefb
commit 76c101938d
3 changed files with 29 additions and 13 deletions

View file

@ -0,0 +1,28 @@
import { Controller } from '@hotwired/stimulus';
import M from '@materializecss/materialize';
export default class extends Controller {
static values = {
edge: { type: String, default: 'left' },
};
connect() {
this.instance = M.FloatingActionButton.init(this.element);
}
autoDisplay() {
const scrolled = (window.innerHeight + window.scrollY) >= document.body.offsetHeight;
if (scrolled) {
this.toggleScroll = true;
this.instance.open();
} else if (this.toggleScroll === true) {
this.toggleScroll = false;
this.instance.close();
}
}
disconnect() {
this.instance.destroy();
}
}