@xwadex/fesd-next 0.3.26 → 0.3.27

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.
@@ -11,11 +11,18 @@ export function useCollapse({ defaultOpen = false, transDuration = 0.3, transTim
11
11
  if (!isAnimatingRef.current)
12
12
  return setOpen(state);
13
13
  nextOpenRef.current = state;
14
- }, [open]);
14
+ }, []);
15
+ const setTransitionInit = (target) => {
16
+ target.style.overflow = "hidden";
17
+ target.style.transition = transDuration + "s";
18
+ target.style.transitionDelay = transDelay + "s";
19
+ target.style.transitionTimingFunction = transTiming;
20
+ };
15
21
  const setExpandTransition = useCallback((events) => {
16
22
  const target = contentRef.current;
17
23
  if (!target)
18
24
  return;
25
+ setTransitionInit(target);
19
26
  if (events === "start") {
20
27
  target.style.maxHeight = target.scrollHeight + "px";
21
28
  target.style.opacity = transMode == "fade" ? "1" : "";
@@ -29,7 +36,7 @@ export function useCollapse({ defaultOpen = false, transDuration = 0.3, transTim
29
36
  target.style.opacity = transMode == "fade" ? "0" : "";
30
37
  }
31
38
  target.offsetHeight; // hack to force reflow
32
- }, [transMode]);
39
+ }, [transMode, transDuration, transTiming, transDelay]);
33
40
  const expandAnimate = useCallback(async (state) => {
34
41
  if (!contentRef?.current)
35
42
  return;
@@ -37,7 +44,7 @@ export function useCollapse({ defaultOpen = false, transDuration = 0.3, transTim
37
44
  onChange?.(state);
38
45
  setExpandTransition("start");
39
46
  const target = contentRef.current;
40
- await sleep(state ? getDomTransTime(target) : 0);
47
+ await sleep(state ? getDomTransTime(target) + 100 : 0);
41
48
  setExpandTransition(state ? "open" : "close");
42
49
  state ? onExpand?.(state) : onClose?.(state);
43
50
  isAnimatingRef.current = false;
@@ -51,10 +58,7 @@ export function useCollapse({ defaultOpen = false, transDuration = 0.3, transTim
51
58
  const target = contentRef.current;
52
59
  if (!target)
53
60
  return;
54
- target.style.overflow = "hidden";
55
- target.style.transition = transDuration + "s";
56
- target.style.transitionDelay = transDelay + "s";
57
- target.style.transitionTimingFunction = transTiming;
61
+ setTransitionInit(target);
58
62
  if (defaultOpen)
59
63
  startTransition(() => setExpandTransition("start"));
60
64
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwadex/fesd-next",
3
- "version": "0.3.26",
3
+ "version": "0.3.27",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",