mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
fix(Popup): theme settings hidden in SEQTA + animations fixes
This commit is contained in:
@@ -17,31 +17,38 @@
|
|||||||
const playAnimation = (keyframe: any) => {
|
const playAnimation = (keyframe: any) => {
|
||||||
if (divElement && keyframe) {
|
if (divElement && keyframe) {
|
||||||
let animationOptions = transition;
|
let animationOptions = transition;
|
||||||
|
let finalKeyframe = { ...keyframe };
|
||||||
|
|
||||||
|
if (finalKeyframe.height === 'auto') {
|
||||||
|
divElement.style.visibility = 'hidden';
|
||||||
|
divElement.style.height = 'auto';
|
||||||
|
const height = divElement.offsetHeight;
|
||||||
|
divElement.style.height = divElement.style.height || '0px';
|
||||||
|
divElement.style.visibility = '';
|
||||||
|
|
||||||
|
finalKeyframe.height = `${height}px`;
|
||||||
|
}
|
||||||
|
|
||||||
// If transition is not defined or is of type 'spring', use spring animations
|
|
||||||
if (!transition || transition.type === 'spring') {
|
if (!transition || transition.type === 'spring') {
|
||||||
animationOptions = {
|
animationOptions = {
|
||||||
easing: spring(transition || { stiffness: 250, damping: 25 }),
|
easing: spring(transition || { stiffness: 250, damping: 25 }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const animation = motionAnimate(divElement, keyframe, animationOptions);
|
const animation = motionAnimate(divElement, finalKeyframe, animationOptions);
|
||||||
return animation.finished;
|
return animation.finished;
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
// Apply initial state if provided
|
|
||||||
if (initial) {
|
if (initial) {
|
||||||
await playAnimation(initial);
|
Object.assign(divElement.style, initial);
|
||||||
}
|
await playAnimation(animate || {});
|
||||||
// Then animate to the `animate` state
|
} else if (animate) {
|
||||||
if (animate) {
|
|
||||||
await playAnimation(animate);
|
await playAnimation(animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch animation end event
|
|
||||||
dispatch('animationend');
|
dispatch('animationend');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -53,7 +60,6 @@
|
|||||||
dispatch('animationend');
|
dispatch('animationend');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle unmounting with the `exit` animation
|
|
||||||
onDestroy(async () => {
|
onDestroy(async () => {
|
||||||
if (exit) {
|
if (exit) {
|
||||||
await playAnimation(exit);
|
await playAnimation(exit);
|
||||||
|
|||||||
@@ -63,8 +63,6 @@
|
|||||||
const deleteCustomShortcut = (index: number) => {
|
const deleteCustomShortcut = (index: number) => {
|
||||||
settingsState.customshortcuts = settingsState.customshortcuts.filter((_, i) => i !== index);
|
settingsState.customshortcuts = settingsState.customshortcuts.filter((_, i) => i !== index);
|
||||||
};
|
};
|
||||||
|
|
||||||
const springTransition = { type: 'spring', damping: 20 };
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#snippet Shortcuts([index, Shortcut]: [string, { name: string, enabled: boolean }]) }
|
{#snippet Shortcuts([index, Shortcut]: [string, { name: string, enabled: boolean }]) }
|
||||||
@@ -81,16 +79,16 @@
|
|||||||
<div>
|
<div>
|
||||||
<MotionDiv
|
<MotionDiv
|
||||||
initial={{ opacity: 0, height: 0 }}
|
initial={{ opacity: 0, height: 0 }}
|
||||||
animate={isFormVisible ? { opacity: 1, height: "auto" } : { opacity: 0, height: 0 }}
|
animate={isFormVisible ? { opacity: 1, height: 'auto' } : { opacity: 0, height: 0 }}
|
||||||
exit={{ opacity: 0, height: 0 }}
|
exit={{ opacity: 0, height: 0 }}
|
||||||
transition={springTransition}
|
transition={{ duration: 0.3 }}
|
||||||
>
|
>
|
||||||
{#if isFormVisible}
|
{#if isFormVisible}
|
||||||
<div class="flex flex-col items-center">
|
<div class="flex flex-col items-center">
|
||||||
<MotionDiv
|
<MotionDiv
|
||||||
initial={{ opacity: 0, y: -10 }}
|
initial={{ opacity: 0, y: -10 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ delay: 0.1, duration: 0.4 }}
|
transition={{ delay: 0.1, duration: 0.5 }}
|
||||||
class="w-full"
|
class="w-full"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@@ -103,7 +101,7 @@
|
|||||||
<MotionDiv
|
<MotionDiv
|
||||||
initial={{ opacity: 0, y: -10 }}
|
initial={{ opacity: 0, y: -10 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ delay: 0.2, duration: 0.4 }}
|
transition={{ delay: 0.2, duration: 0.5 }}
|
||||||
class="w-full"
|
class="w-full"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@@ -118,31 +116,18 @@
|
|||||||
</MotionDiv>
|
</MotionDiv>
|
||||||
|
|
||||||
<MotionDiv
|
<MotionDiv
|
||||||
animate={isFormVisible ? { y: 0 } : { y: 0 }}
|
initial={{ opacity: 0, y: 20 }}
|
||||||
transition={springTransition}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
|
transition={{ duration: 0.3 }}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="w-full px-4 py-2 mb-4 text-[13px] dark:text-white transition rounded-xl bg-zinc-200 dark:bg-zinc-700/50"
|
class="w-full px-4 py-2 mb-4 text-[13px] dark:text-white transition rounded-xl bg-zinc-200 dark:bg-zinc-700/50"
|
||||||
onclick={isFormVisible ? addNewCustomShortcut : toggleForm}
|
onclick={isFormVisible ? addNewCustomShortcut : toggleForm}
|
||||||
>
|
>
|
||||||
{#if isFormVisible}
|
{#if isFormVisible}
|
||||||
<MotionDiv
|
Add
|
||||||
initial={{ opacity: 0 }}
|
|
||||||
animate={{ opacity: 1 }}
|
|
||||||
exit={{ opacity: 0 }}
|
|
||||||
transition={{ duration: 0.7 }}
|
|
||||||
>
|
|
||||||
Add
|
|
||||||
</MotionDiv>
|
|
||||||
{:else}
|
{:else}
|
||||||
<MotionDiv
|
Add Custom Shortcut
|
||||||
initial={{ opacity: 0 }}
|
|
||||||
animate={{ opacity: 1 }}
|
|
||||||
exit={{ opacity: 0 }}
|
|
||||||
transition={{ duration: 0.3 }}
|
|
||||||
>
|
|
||||||
Add Custom Shortcut
|
|
||||||
</MotionDiv>
|
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
</MotionDiv>
|
</MotionDiv>
|
||||||
|
|||||||
Reference in New Issue
Block a user