mirror of
https://github.com/wallabag/wallabag.git
synced 2025-06-27 16:36:00 +00:00
29 lines
649 B
JavaScript
29 lines
649 B
JavaScript
|
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();
|
||
|
}
|
||
|
}
|