2025-03-02 12:32:11 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-08 14:56:53 +01:00
|
|
|
click() {
|
|
|
|
this.dispatch('click');
|
|
|
|
}
|
|
|
|
|
2025-03-02 12:32:11 +01:00
|
|
|
disconnect() {
|
|
|
|
this.instance.destroy();
|
|
|
|
}
|
|
|
|
}
|