svelte-ag 0.0.2-dev.82 → 0.0.2-dev.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,47 +74,30 @@
74
74
  children
75
75
  }: Props = $props();
76
76
 
77
- let animationComplete = $state<boolean>(true);
77
+ let animationComplete = $state<boolean>(disableInitialAnimation);
78
78
  let isInitialRender = $state(true);
79
79
  //svelte-ignore non_reactive_update
80
80
  let growHeightElement: HTMLDivElement | undefined;
81
81
 
82
82
  function handleAnimationEnd(e: AnimationEvent) {
83
- if (!visible) {
84
- animationComplete = true;
85
- } else {
86
- animationComplete = false;
87
- }
88
-
89
- // Mark initial render as complete after animation
90
- isInitialRender = false;
91
-
92
- if (onAnimationComplete) {
93
- onAnimationComplete(visible);
94
- }
83
+ animationComplete = true;
84
+ onAnimationComplete?.(visible);
95
85
  }
96
86
 
97
87
  // Reset animation state when visibility changes
98
88
  watch(
99
89
  () => visible,
100
- (newValue) => {
101
- if (newValue) {
102
- animationComplete = false;
103
- }
90
+ () => {
91
+ isInitialRender = false;
92
+ animationComplete = false;
104
93
  },
105
- { lazy: false }
94
+ // Dont run on mount
95
+ { lazy: true }
106
96
  );
107
97
 
108
- // Set initial render to false when component mounts if disableInitialAnimation is true
109
- $effect(() => {
110
- if (disableInitialAnimation) {
111
- isInitialRender = false;
112
- }
113
- });
114
-
115
98
  const dataState = $derived(visible ? 'visible' : 'hidden');
116
99
  // Skip animation classes on initial render when disableInitialAnimation is true
117
- const shouldApplyAnimationClasses = $derived(!isInitialRender || !disableInitialAnimation);
100
+ const shouldApplyAnimationClasses = $derived(!(isInitialRender && disableInitialAnimation));
118
101
 
119
102
  // Duration in ms for animations
120
103
  const durationMap = {
@@ -210,11 +193,14 @@
210
193
  }
211
194
  }
212
195
 
213
- $effect(() => {
214
- if (animation === 'growHeight') {
215
- animateHeight();
196
+ watch(
197
+ () => visible,
198
+ () => {
199
+ if (animation === 'growHeight') {
200
+ animateHeight();
201
+ }
216
202
  }
217
- });
203
+ );
218
204
  </script>
219
205
 
220
206
  {#if animation === 'growHeight'}
@@ -1 +1 @@
1
- {"version":3,"file":"animated.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/animated/animated.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDA2C3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAGvE,OAAO,EAAM,KAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKpD,MAAM,MAAM,KAAK,GAAG,cAAc,CAAC,iBAAiB,CAAC,GAAG;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAwLJ,QAAA,MAAM,QAAQ,kDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"animated.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/animated/animated.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDA2C3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAGvE,OAAO,EAAM,KAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKpD,MAAM,MAAM,KAAK,GAAG,cAAc,CAAC,iBAAiB,CAAC,GAAG;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA0KJ,QAAA,MAAM,QAAQ,kDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "svelte-ag",
3
3
  "description": "Useful svelte components",
4
- "version": "0.0.2-dev.82",
4
+ "version": "0.0.2-dev.83",
5
5
  "author": "Alexander Hornung",
6
6
  "bugs": "https://github.com/ageorgeh/cms/issues",
7
7
  "dependencies": {
@@ -24,7 +24,7 @@
24
24
  "formsnap": "2.0.1",
25
25
  "valibot": "1.1.0",
26
26
  "radash": "12.1.0",
27
- "ts-ag": "0.0.1-dev.2"
27
+ "ts-ag": "0.0.1-dev.3"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "svelte": "^5.28.2",
@@ -74,47 +74,30 @@
74
74
  children
75
75
  }: Props = $props();
76
76
 
77
- let animationComplete = $state<boolean>(true);
77
+ let animationComplete = $state<boolean>(disableInitialAnimation);
78
78
  let isInitialRender = $state(true);
79
79
  //svelte-ignore non_reactive_update
80
80
  let growHeightElement: HTMLDivElement | undefined;
81
81
 
82
82
  function handleAnimationEnd(e: AnimationEvent) {
83
- if (!visible) {
84
- animationComplete = true;
85
- } else {
86
- animationComplete = false;
87
- }
88
-
89
- // Mark initial render as complete after animation
90
- isInitialRender = false;
91
-
92
- if (onAnimationComplete) {
93
- onAnimationComplete(visible);
94
- }
83
+ animationComplete = true;
84
+ onAnimationComplete?.(visible);
95
85
  }
96
86
 
97
87
  // Reset animation state when visibility changes
98
88
  watch(
99
89
  () => visible,
100
- (newValue) => {
101
- if (newValue) {
102
- animationComplete = false;
103
- }
90
+ () => {
91
+ isInitialRender = false;
92
+ animationComplete = false;
104
93
  },
105
- { lazy: false }
94
+ // Dont run on mount
95
+ { lazy: true }
106
96
  );
107
97
 
108
- // Set initial render to false when component mounts if disableInitialAnimation is true
109
- $effect(() => {
110
- if (disableInitialAnimation) {
111
- isInitialRender = false;
112
- }
113
- });
114
-
115
98
  const dataState = $derived(visible ? 'visible' : 'hidden');
116
99
  // Skip animation classes on initial render when disableInitialAnimation is true
117
- const shouldApplyAnimationClasses = $derived(!isInitialRender || !disableInitialAnimation);
100
+ const shouldApplyAnimationClasses = $derived(!(isInitialRender && disableInitialAnimation));
118
101
 
119
102
  // Duration in ms for animations
120
103
  const durationMap = {
@@ -210,11 +193,14 @@
210
193
  }
211
194
  }
212
195
 
213
- $effect(() => {
214
- if (animation === 'growHeight') {
215
- animateHeight();
196
+ watch(
197
+ () => visible,
198
+ () => {
199
+ if (animation === 'growHeight') {
200
+ animateHeight();
201
+ }
216
202
  }
217
- });
203
+ );
218
204
  </script>
219
205
 
220
206
  {#if animation === 'growHeight'}