Files
fizzy/app/javascript/controllers/animation_controller.js
T
2024-10-11 20:14:09 -05:00

18 lines
377 B
JavaScript

import { Controller } from "@hotwired/stimulus"
import { nextFrame } from "helpers"
export default class extends Controller {
static classes = [ "play" ]
async play() {
await nextFrame()
this.element.classList.remove(this.playClass)
this.#forceReflow()
this.element.classList.add(this.playClass)
}
#forceReflow() {
this.element.offsetWidth
}
}