Skip to content

Commit

Permalink
urg
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Apr 15, 2024
1 parent 25aa338 commit f0c81e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
3 changes: 2 additions & 1 deletion packages/bits-ui/src/lib/bits/accordion/accordion.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ class AccordionContentState {

onMount(() => {
requestAnimationFrame(() => {
console.log("calling animation frame");
this.isMountAnimationPrevented.value = false;
});
});
Expand All @@ -338,6 +337,8 @@ class AccordionContentState {
if (!this.isMountAnimationPrevented.value) {
const transitionDuration = this.currentStyle.value.transitionDuration;
const animationName = this.currentStyle.value.animationName;
console.log("transitionDuration", transitionDuration);
console.log("animationName", animationName);
if (transitionDuration) {
node.style.transitionDuration = transitionDuration;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/bits-ui/src/lib/internal/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export function verifyContextDeps(...deps: symbol[]) {
const ctx = getAllContexts();
const missing = deps.filter((dep) => !ctx.has(dep));
if (missing.length > 0) {
throw new Error(`Missing context dependencies: ${missing.join(", ")}`);
// TODO: symbols break our ability to show the name of the missing context. :/
throw new Error(`Missing context dependencies`);
}
}
}
15 changes: 2 additions & 13 deletions packages/bits-ui/src/lib/internal/use-presence.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ export function usePresence(present: Box<boolean>, node: Box<HTMLElement | undef
const currAnimationName = getAnimationName(node.value);

if (currPresent) {
console.log("MOUNT");
dispatch("MOUNT");
} else if (currAnimationName === "none" || styles.value?.display === "none") {
// If there is no exit animation or the element is hidden, animations won't run
// so we unmount instantly
console.log("UNMOUNT");
dispatch("UNMOUNT");
} else {
/**
Expand All @@ -47,10 +45,8 @@ export function usePresence(present: Box<boolean>, node: Box<HTMLElement | undef
*/
const isAnimating = prevAnimationName !== currAnimationName;
if (prevPresent && isAnimating) {
console.log("ANIMATION_OUT");
dispatch("ANIMATION_OUT");
} else {
console.log("UNMOUNT");
dispatch("UNMOUNT");
}
}
Expand All @@ -65,22 +61,16 @@ export function usePresence(present: Box<boolean>, node: Box<HTMLElement | undef
*/

function handleAnimationEnd(event: AnimationEvent) {
console.log("handling animation end");
const currAnimationName = getAnimationName(node.value);
const isCurrentAnimation = currAnimationName.includes(event.animationName);
const isCurrentAnimation =
currAnimationName.includes(event.animationName) || currAnimationName === "none";

if (event.target === node.value && isCurrentAnimation) {
console.log("ANIMATION_END");
dispatch("ANIMATION_END");
}
if (event.target === node.value && currAnimationName === "none") {
console.log("ANIMATION_END");
dispatch("ANIMATION_END");
}
}

function handleAnimationStart(event: AnimationEvent) {
console.log("handling animation start");
if (event.target === node.value) {
prevAnimationNameState.value = getAnimationName(node.value);
}
Expand All @@ -95,7 +85,6 @@ export function usePresence(present: Box<boolean>, node: Box<HTMLElement | undef
currNode.addEventListener("animationcancel", handleAnimationEnd);
currNode.addEventListener("animationend", handleAnimationEnd);
} else {
console.log("ANIMATION_END");
dispatch("ANIMATION_END");
prevNode?.removeEventListener("animationstart", handleAnimationStart);
prevNode?.removeEventListener("animationcancel", handleAnimationEnd);
Expand Down

0 comments on commit f0c81e0

Please sign in to comment.