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:
parent
a7a4c5fefb
commit
76c101938d
3 changed files with 29 additions and 13 deletions
28
assets/controllers/materialize/fab_controller.js
Normal file
28
assets/controllers/materialize/fab_controller.js
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue