Files
base/node_modules/bits-ui/dist/internal/presence-manager.svelte.js
T
eewing ec317eb17c
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m11s
INIT
2026-02-18 15:17:47 -06:00

35 lines
1.0 KiB
JavaScript

import { watch } from "runed";
import { AnimationsComplete } from "./animations-complete.js";
export class PresenceManager {
#opts;
#enabled;
#afterAnimations;
#shouldRender = $state(false);
constructor(opts) {
this.#opts = opts;
this.#shouldRender = opts.open.current;
this.#enabled = opts.enabled ?? true;
this.#afterAnimations = new AnimationsComplete({
ref: this.#opts.ref,
afterTick: this.#opts.open,
});
watch(() => this.#opts.open.current, (isOpen) => {
if (isOpen)
this.#shouldRender = true;
if (!this.#enabled)
return;
this.#afterAnimations.run(() => {
if (isOpen === this.#opts.open.current) {
if (!this.#opts.open.current) {
this.#shouldRender = false;
}
this.#opts.onComplete?.();
}
});
});
}
get shouldRender() {
return this.#shouldRender;
}
}