Sha256: 31c17402f917f88240df0013295b2043c76e170c3465f90ce0a95f2e5643372e
Contents?: true
Size: 800 Bytes
Versions: 66
Compression:
Stored size: 800 Bytes
Contents
import { Controller } from "@hotwired/stimulus"; import { Transition } from "koi/utils/transition"; export default class ShowHideController extends Controller { static targets = ["content"]; toggle() { const element = this.contentTarget; const hide = element.toggleAttribute("data-collapsed"); // cancel previous animation, if any if (this.transition) this.transition.cancel(); const transition = (this.transition = new Transition(element) .addCallback("starting", function () { element.setAttribute("data-collapsed-transitioning", "true"); }) .addCallback("complete", function () { element.removeAttribute("data-collapsed-transitioning"); })); hide ? transition.collapse() : transition.expand(); transition.start(); } }
Version data entries
66 entries across 66 versions & 1 rubygems