16 lines
383 B
JavaScript
16 lines
383 B
JavaScript
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),
|
|
);
|
|
}
|
|
}
|