Added stimulus and turbo. Added first controller to close sidebar.
This commit is contained in:
15
assets/controllers/closable_controller.js
Normal file
15
assets/controllers/closable_controller.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
async close(){
|
||||
this.element.style.width = '0';
|
||||
await this.#waitForAnimation();
|
||||
this.element.remove();
|
||||
}
|
||||
|
||||
#waitForAnimation() {
|
||||
return Promise.all(
|
||||
this.element.getAnimations().map((animation) => animation.finished),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user