page-transition 0.1.0-beta.42 → 0.1.0-beta.44

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.
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
- # page-transition
2
- A page transition library for the Next.js App Router.
1
+ # <img src="./assets/logo.svg" width="32"/>&nbsp;&nbsp;page-transition
2
+ A page transition library for the Next.js App Router.
3
+ <br/>
4
+ [![Live Demo ↗](https://img.shields.io/badge/Live_Demo_%E2%86%97-000000?style=for-the-badge)](https://simon-schindler.github.io/page-transition-demo/)
3
5
 
4
- [![Live Demo ↗](https://img.shields.io/badge/Live_Demo_%E2%86%97-000000?style=for-the-badge)](https://simon-schindler.github.io/page-transition-demo/)
5
-
6
-
6
+
7
7
  ## Features
8
8
 
9
9
  - CSS & Manual mode
10
10
  - Scroll restoration
11
11
 
12
12
  ## Install
13
- ![Version](https://img.shields.io/badge/v_0.1.0--beta.38-000000) ![78.5 KB](https://img.shields.io/badge/79.3_KB-1677FF)
13
+ ![Version](https://img.shields.io/badge/v_0.1.0--beta.43-000000) ![86.9 KB](https://img.shields.io/badge/86.9_KB-1677FF)
14
14
 
15
15
  `npm install page-transition@beta`
16
16
 
@@ -50,8 +50,9 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
50
50
  | Option | Type | Default |
51
51
  |---|---|---|
52
52
  | transitionProperty | "opacity" \| "clip-path" | "opacity" |
53
- | overlayCount | number | 0 |
54
- | mirror | boolean | false |
53
+ | wait | boolean | false |
54
+ | items | [number, number] | [0, 0] |
55
+
55
56
 
56
57
  **Prop Descriptions**
57
58
 
@@ -64,11 +65,17 @@ The component rendered outside the transition container.
64
65
  **options.transitionProperty**
65
66
  Defines which property transitionend waits for.
66
67
 
67
- **options.overlayCount**
68
- Defines how many overlay items should be created.
69
-
70
- **options.mirror**
71
- Creates the same number of items as specified by overlayCount.
68
+ **options.wait**
69
+ false: Reverses the current enter transition.
70
+ true: Waits for the current enter transition to finish before starting the new transition.
71
+
72
+ **options.items**
73
+ <br/>
74
+ options.items[0]
75
+ Number of items in the first group. Each item receives the `.overlay-item` class.
76
+ <br/>
77
+ options.items[1]
78
+ Number of items in the second group. Each item receives the `.second-item` class.
72
79
 
73
80
 
74
81
  ```tsx
@@ -76,7 +83,7 @@ Creates the same number of items as specified by overlayCount.
76
83
  header={<Header/>}
77
84
  options={{
78
85
  transitionProperty: "clip-path",
79
- overlayCount: 1
86
+ items: [1, 0]
80
87
  }}
81
88
  >
82
89
  {children}
@@ -111,14 +118,15 @@ Triggers the transition.
111
118
 
112
119
  The `TransitionProvider` uses a container with a `data-transition` attribute. When navigation starts, it adds the `exit` class and waits for the transitionend event of the configured transition property.
113
120
 
114
- Once the transition ends, navigation is performed and the scroll position is restored using window.history.state.scrollY.
121
+ Once the transition ends, the scroll position is restored and navigation is performed.
115
122
 
116
123
  After navigation, the `exit` class is removed and the `enter` class is added. Once the next transitionend event fires, the enter class is removed.
117
124
 
118
- For overlay animations, a `.overlay-wrapper` is available. You can add overlay items by setting the `overlayCount` option.
125
+ For overlay animations, an `.overlay-wrapper` is available. You can configure the number of overlay items using the options.items array. The transition waits for the first item group to finish its transition.
126
+ <br/>
127
+ When `wait` is `false`, both item groups must contain the same number of items for reverse delays to work correctly. Both groups will then receive the same delay durations when reversing a staggered enter transition.
128
+
119
129
 
120
- If mirror is set to true, the same number of div elements specified by `overlayCount` are added to the `.overlay-wrapper` with the class `mirror-item`. The transitionend dont wait for mirror items. This ideal for mirror effects.
121
-
122
130
  *At the moment, it only supports duration and delay in seconds.*
123
131
 
124
132
  To access the overlay wrapper and its items, use `useTransitionContext`.
@@ -126,7 +134,7 @@ To access the overlay wrapper and its items, use `useTransitionContext`.
126
134
  ```ts
127
135
  import { useTransitionContext } from "page-transition"
128
136
 
129
- const {overlayWrapper, overlayItems} = useTransitionContext()
137
+ const { overlayWrapper, overlayItems } = useTransitionContext()
130
138
 
131
139
  ```
132
140
 
@@ -138,7 +146,7 @@ options
138
146
 
139
147
  ```ts
140
148
  transitionProperty: "opacity"
141
- overlayCount: 0
149
+
142
150
  ```
143
151
 
144
152
  ```css
@@ -165,7 +173,7 @@ options
165
173
 
166
174
  ```ts
167
175
  transitionProperty: "clip-path"
168
- overlayCount: 1
176
+ items: [1, 0]
169
177
  ```
170
178
 
171
179
  ```css
@@ -200,7 +208,7 @@ options
200
208
 
201
209
  ```ts
202
210
  transitionProperty: "clip-path"
203
- overlayCount: 10
211
+ items: [10, 0]
204
212
  ```
205
213
 
206
214
  ```scss
@@ -245,8 +253,7 @@ options
245
253
 
246
254
  ```ts
247
255
  transitionProperty: "clip-path"
248
- overlayCount: 10
249
- mirror: true
256
+ items: [10, 10]
250
257
  ```
251
258
 
252
259
  ```scss
@@ -286,8 +293,8 @@ mirror: true
286
293
  }
287
294
  }
288
295
  }
289
- // .mirror-item
290
- [data-transition] .mirror-item{
296
+ // .second-item
297
+ [data-transition] .second-item{
291
298
  grid-row: 2;
292
299
  background: black;
293
300
 
@@ -295,7 +302,7 @@ mirror: true
295
302
  will-change: clip-path;
296
303
  clip-path: inset(100% 0 0 0);
297
304
  }
298
- [data-transition].exit .mirror-item{
305
+ [data-transition].exit .second-item{
299
306
  grid-row: 2;
300
307
  clip-path: inset(0 -1px 0 -1px);
301
308
  transition: clip-path 1.2s ease;
@@ -305,7 +312,7 @@ mirror: true
305
312
  }
306
313
  }
307
314
  }
308
- [data-transition].enter .mirror-item{
315
+ [data-transition].enter .second-item{
309
316
  grid-row: 2;
310
317
  clip-path: inset(100% -1px 0 -1px);
311
318
  transition: clip-path 1.2s ease;
@@ -4,7 +4,7 @@ import { useTransitionContext } from "../context/TransitionContext";
4
4
  export function TransitionLink({ href, className, prefetch, onClick, children }) {
5
5
  const { handleLinkClick } = useTransitionContext();
6
6
  return (_jsx(Link, { href: href, onClick: (e) => {
7
- handleLinkClick.current(e, href);
8
7
  onClick?.(e);
8
+ handleLinkClick.current(e, href);
9
9
  }, className: className, prefetch: prefetch, children: children }));
10
10
  }
@@ -1,8 +1,8 @@
1
1
  import type { ReactNode } from "react";
2
2
  interface TransitionOptions {
3
3
  transitionProperty?: 'opacity' | 'clip-path';
4
- overlayCount?: number;
5
- mirror?: boolean;
4
+ wait?: boolean;
5
+ items?: [number, number];
6
6
  }
7
7
  interface ProviderProps {
8
8
  header?: ReactNode;
@@ -16,14 +16,14 @@ import { pollTransitionStart } from "../functions/pollTransitionStart";
16
16
  export function CssTransitionProvider({ header, options, children }) {
17
17
  const defaultOptions = {
18
18
  transitionProperty: 'opacity',
19
- overlayCount: 0,
20
- mirror: false,
19
+ wait: false,
20
+ items: [0, 0],
21
21
  ...options
22
22
  };
23
23
  const container = useRef(null);
24
24
  const overlayWrapper = useRef(null);
25
25
  const overlayItems = useRef([]);
26
- const mirrorItems = useRef([]);
26
+ const secondItems = useRef([]);
27
27
  const pathname = usePathname();
28
28
  const currentPathname = useRef(pathname);
29
29
  const mount = useRef({
@@ -40,7 +40,9 @@ export function CssTransitionProvider({ header, options, children }) {
40
40
  return this._lock;
41
41
  },
42
42
  set lock(value) {
43
- if (delayStep.current === 0 || overlayItems.current.length < 2) {
43
+ if (delayStep.current === 0 ||
44
+ overlayItems.current.length < 2 ||
45
+ defaultOptions.wait === true) {
44
46
  if (this._lock === false)
45
47
  this._lock = true;
46
48
  return;
@@ -53,10 +55,9 @@ export function CssTransitionProvider({ header, options, children }) {
53
55
  const handleLinkClick = useRef(() => { });
54
56
  const transitionEndHandler = useTransitionEndHandler();
55
57
  const transitionEndData = useTransitionEndData({
56
- elArray: defaultOptions.overlayCount === 0 ? container : overlayItems,
58
+ elArray: defaultOptions.items[0] === 0 ? container : overlayItems,
57
59
  transitionProperty: defaultOptions.transitionProperty,
58
- mirror: defaultOptions.mirror,
59
- mirrorElArray: mirrorItems
60
+ secondElArray: secondItems
60
61
  });
61
62
  const pollRafId = useRef(null);
62
63
  const rafId = useRef(null);
@@ -74,7 +75,8 @@ export function CssTransitionProvider({ header, options, children }) {
74
75
  rafId,
75
76
  rejectFn,
76
77
  delayStep,
77
- duration
78
+ duration,
79
+ wait: defaultOptions.wait
78
80
  });
79
81
  useHandleLinkClick({
80
82
  container,
@@ -91,7 +93,8 @@ export function CssTransitionProvider({ header, options, children }) {
91
93
  rafId,
92
94
  rejectFn,
93
95
  delayStep,
94
- duration
96
+ duration,
97
+ wait: defaultOptions.wait
95
98
  });
96
99
  useScrollRestoration();
97
100
  const removeEnter = useTransitionEndObj({
@@ -129,18 +132,18 @@ export function CssTransitionProvider({ header, options, children }) {
129
132
  });
130
133
  currentPathname.current = window.location.pathname;
131
134
  reverse.current.lock = false;
132
- if (delayStep.current === null && defaultOptions.overlayCount > 1) {
133
- delayStep.current = parseDelay(transitionEndData.current.elArray);
135
+ if (delayStep.current === null && defaultOptions.items[0] > 1) {
136
+ delayStep.current = defaultOptions.wait ? 0 :
137
+ parseDelay(transitionEndData.current.elArray);
134
138
  }
135
- if (duration.current === null) {
136
- duration.current = parseDuration(transitionEndData.current.elArray[0]);
137
- duration.current = (duration.current ?? 0) * 1000 / 2;
139
+ if (duration.current === null && !defaultOptions.wait) {
140
+ duration.current = parseDuration(transitionEndData.current.elArray[0]) * 1000 / 3;
138
141
  }
139
142
  }, [pathname]);
140
143
  const value = useMemo(() => ({ handleLinkClick, overlayWrapper, overlayItems }), []);
141
- return (_jsxs(TransitionContext.Provider, { value: value, children: [header, _jsxs("div", { ref: container, "data-transition": true, children: [_jsxs("div", { ref: overlayWrapper, className: "overlay-wrapper", children: [defaultOptions.overlayCount > 0 && Array.from({ length: defaultOptions.overlayCount }).map((_, i) => (_jsx("div", { ref: (el) => {
144
+ return (_jsxs(TransitionContext.Provider, { value: value, children: [header, _jsxs("div", { ref: container, "data-transition": true, children: [_jsxs("div", { ref: overlayWrapper, className: "overlay-wrapper", children: [defaultOptions.items[0] > 0 && Array.from({ length: defaultOptions.items[0] }).map((_, i) => (_jsx("div", { ref: (el) => {
142
145
  overlayItems.current[i] = el;
143
- }, className: "overlay-item" }, i))), defaultOptions.mirror && Array.from({ length: defaultOptions.overlayCount }).map((_, i) => (_jsx("div", { ref: (el) => {
144
- mirrorItems.current[i] = el;
146
+ }, className: "overlay-item" }, i))), defaultOptions.items[1] > 0 && Array.from({ length: defaultOptions.items[1] }).map((_, i) => (_jsx("div", { ref: (el) => {
147
+ secondItems.current[i] = el;
145
148
  }, className: "mirror-item" }, `mirror${i}`)))] }), children] })] }));
146
149
  }
@@ -12,8 +12,8 @@ type Mode = 'css' | 'manual';
12
12
  type TransitionProperty = 'opacity' | 'clip-path';
13
13
  interface TransitionOptions {
14
14
  transitionProperty?: TransitionProperty;
15
- overlayCount?: number;
16
- mirror?: boolean;
15
+ wait?: boolean;
16
+ items?: [number, number];
17
17
  }
18
18
  interface ProviderProps {
19
19
  header?: ReactNode;
@@ -1 +1 @@
1
- export declare function parseDuration(el: HTMLElement | null): number | null;
1
+ export declare function parseDuration(el: HTMLElement | null): number;
@@ -1,6 +1,5 @@
1
1
  export function parseDuration(el) {
2
2
  if (!el)
3
- return null;
4
- const duration = parseFloat(getComputedStyle(el).transitionDuration);
5
- return duration ? duration : 250;
3
+ return 0;
4
+ return parseFloat(getComputedStyle(el).transitionDuration);
6
5
  }
@@ -10,21 +10,22 @@ export function transtionEndReverse({ transitionEndObj, transitionEndHandler, re
10
10
  transitionProperty: endObj.transitionProperty,
11
11
  delayStep: delayStep.current
12
12
  });
13
- if (endObj.mirror) {
13
+ if (endObj.secondElArray.length === endObj.elArray.length) {
14
14
  setDelayReverse({
15
- elArray: endObj.mirrorElArray,
15
+ elArray: endObj.secondElArray,
16
16
  transitionProperty: endObj.transitionProperty,
17
17
  delayStep: delayStep.current
18
18
  });
19
19
  }
20
20
  const firstEl = endObj.elArray[0];
21
21
  const handler = (e) => {
22
- console.log('transitionEndReverse handler fired');
23
22
  if (e.propertyName !== endObj.transitionProperty ||
24
23
  e.target !== e.currentTarget)
25
24
  return;
26
25
  resetDelay(endObj.elArray);
27
- resetDelay(endObj.mirrorElArray);
26
+ if (endObj.secondElArray.length === endObj.elArray.length) {
27
+ resetDelay(endObj.secondElArray);
28
+ }
28
29
  reverse.current.lock = true;
29
30
  firstEl?.removeEventListener('transitionend', handler);
30
31
  endObj.fn?.();
@@ -36,13 +36,6 @@ export function updatePlaybackRate({ rafId, rejectFn, elArray, transitionPropert
36
36
  currentTime <= 0 && start)
37
37
  return;
38
38
  obj.updatePlaybackRate(progress);
39
- console.log("AFTER", {
40
- meinProg: progress,
41
- rate: obj.playbackRate,
42
- currentTime: obj.currentTime,
43
- playState: obj.playState,
44
- startTime: obj.startTime,
45
- });
46
39
  });
47
40
  if (target && progress >= 1 || !target && progress <= 0) {
48
41
  if (rafId.current !== null) {
@@ -19,6 +19,7 @@ interface Props {
19
19
  rejectFn: RefObject<(() => void) | null>;
20
20
  delayStep: RefObject<number | null>;
21
21
  duration: RefObject<number | null>;
22
+ wait: boolean;
22
23
  }
23
- export declare function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn, delayStep, duration }: Props): void;
24
+ export declare function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn, delayStep, duration, wait }: Props): void;
24
25
  export {};
@@ -6,7 +6,7 @@ import { transitionEnd } from "../functions/transitionEnd";
6
6
  import { pollTransitionStart } from "../functions/pollTransitionStart";
7
7
  import { updatePlaybackRate } from "../functions/updatePlaybackRate";
8
8
  import { setPlaybackRate } from "../functions/setPlaybackRate";
9
- export function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn, delayStep, duration }) {
9
+ export function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn, delayStep, duration, wait }) {
10
10
  const router = useRouter();
11
11
  const afterExitFn = useRef(null);
12
12
  const nextPage = useRef(null);
@@ -66,6 +66,7 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
66
66
  }
67
67
  rejectFn.current?.();
68
68
  container.current?.classList.remove('enter');
69
+ void container.current?.offsetWidth;
69
70
  container.current?.classList.add('exit');
70
71
  state.current = 'exiting';
71
72
  transitionEnd({
@@ -98,6 +99,51 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
98
99
  resolve();
99
100
  }
100
101
  }).then(() => {
102
+ if (wait) {
103
+ if (state.current === 'idle' &&
104
+ currentPathname.current === basePathUrl)
105
+ return;
106
+ if (currentPathname.current === basePathUrl
107
+ && state.current === 'exiting') {
108
+ transitionEnd({
109
+ transitionEndObj: afterExit,
110
+ transitionEndHandler,
111
+ reverse,
112
+ delayStep
113
+ });
114
+ return;
115
+ }
116
+ if (state.current === 'entering' &&
117
+ currentPathname.current === basePathUrl) {
118
+ transitionEnd({
119
+ transitionEndObj: removeEnter,
120
+ transitionEndHandler,
121
+ reverse,
122
+ delayStep
123
+ });
124
+ return;
125
+ }
126
+ if (state.current === 'idle' || state.current === 'exiting') {
127
+ transitionEnd({
128
+ transitionEndObj: push,
129
+ transitionEndHandler,
130
+ reverse,
131
+ delayStep
132
+ });
133
+ container.current?.classList.remove('enter');
134
+ container.current?.classList.add('exit');
135
+ state.current = 'exiting';
136
+ }
137
+ else {
138
+ transitionEnd({
139
+ transitionEndObj: afterEntering,
140
+ transitionEndHandler,
141
+ reverse,
142
+ delayStep
143
+ });
144
+ }
145
+ return;
146
+ }
101
147
  if (basePathUrl === currentPathname.current) {
102
148
  if (state.current !== 'exiting')
103
149
  return;
@@ -117,8 +163,8 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
117
163
  delayStep
118
164
  });
119
165
  let elArray = [];
120
- if (transitionEndData.current.mirror) {
121
- elArray = [...transitionEndData.current.mirrorElArray, ...transitionEndData.current.elArray];
166
+ if (transitionEndData.current.secondElArray.length > 0) {
167
+ elArray = [...transitionEndData.current.secondElArray, ...transitionEndData.current.elArray];
122
168
  }
123
169
  else {
124
170
  elArray = [...transitionEndData.current.elArray];
@@ -131,7 +177,7 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
131
177
  target: 0,
132
178
  duration: duration.current ?? 0
133
179
  }).then(() => {
134
- if (basePathUrl === currentPathname.current) {
180
+ if (nextPage.current === currentPathname.current) {
135
181
  transitionEnd({
136
182
  transitionEndObj: afterExit,
137
183
  transitionEndHandler,
@@ -17,6 +17,7 @@ interface Props {
17
17
  rejectFn: RefObject<(() => void) | null>;
18
18
  delayStep: RefObject<number | null>;
19
19
  duration: RefObject<number | null>;
20
+ wait: boolean;
20
21
  }
21
- export declare function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn, delayStep, duration }: Props): void;
22
+ export declare function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn, delayStep, duration, wait }: Props): void;
22
23
  export {};
@@ -5,7 +5,7 @@ import { transitionEnd } from "../functions/transitionEnd";
5
5
  import { pollTransitionStart } from "../functions/pollTransitionStart";
6
6
  import { updatePlaybackRate } from "../functions/updatePlaybackRate";
7
7
  import { setPlaybackRate } from "../functions/setPlaybackRate";
8
- export function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn, delayStep, duration }) {
8
+ export function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn, delayStep, duration, wait }) {
9
9
  const [promise, setPromise] = useState(null);
10
10
  if (promise) {
11
11
  useUse.current = true;
@@ -68,6 +68,7 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
68
68
  }
69
69
  rejectFn.current?.();
70
70
  container.current?.classList.remove('enter');
71
+ void container.current?.offsetWidth;
71
72
  container.current?.classList.add('exit');
72
73
  state.current = 'exiting';
73
74
  transitionEnd({
@@ -98,6 +99,48 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
98
99
  resolveNavigating();
99
100
  }
100
101
  }).then(() => {
102
+ if (wait) {
103
+ if (currentPathname.current === window.location.pathname
104
+ && state.current === 'exiting') {
105
+ transitionEnd({
106
+ transitionEndObj: afterExit,
107
+ transitionEndHandler,
108
+ reverse,
109
+ delayStep
110
+ });
111
+ return;
112
+ }
113
+ if (state.current === 'entering' &&
114
+ currentPathname.current === window.location.pathname) {
115
+ transitionEnd({
116
+ transitionEndObj: removeEnter,
117
+ transitionEndHandler,
118
+ reverse,
119
+ delayStep
120
+ });
121
+ return;
122
+ }
123
+ if (state.current === 'idle' || state.current === 'exiting') {
124
+ transitionEnd({
125
+ transitionEndObj: pop,
126
+ transitionEndHandler,
127
+ reverse,
128
+ delayStep
129
+ });
130
+ container.current?.classList.remove('enter');
131
+ container.current?.classList.add('exit');
132
+ state.current = 'exiting';
133
+ }
134
+ else {
135
+ transitionEnd({
136
+ transitionEndObj: afterEntering,
137
+ transitionEndHandler,
138
+ reverse,
139
+ delayStep
140
+ });
141
+ }
142
+ return;
143
+ }
101
144
  if (currentPathname.current === window.location.pathname) {
102
145
  transitionEnd({
103
146
  transitionEndObj: afterExit,
@@ -115,8 +158,8 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
115
158
  delayStep
116
159
  });
117
160
  let elArray = [];
118
- if (transitionEndData.current.mirror) {
119
- elArray = [...transitionEndData.current.mirrorElArray, ...transitionEndData.current.elArray];
161
+ if (transitionEndData.current.secondElArray.length > 0) {
162
+ elArray = [...transitionEndData.current.secondElArray, ...transitionEndData.current.elArray];
120
163
  }
121
164
  else {
122
165
  elArray = [...transitionEndData.current.elArray];
@@ -3,8 +3,7 @@ import type { TransitionEndData } from "../types/transitionEnd.types";
3
3
  interface Props {
4
4
  elArray: RefObject<HTMLDivElement | null | (HTMLDivElement | null)[]>;
5
5
  transitionProperty: 'opacity' | 'clip-path';
6
- mirror: boolean;
7
- mirrorElArray: RefObject<(HTMLDivElement | null)[]>;
6
+ secondElArray: RefObject<(HTMLDivElement | null)[]>;
8
7
  }
9
- export declare function useTransitionEndData({ elArray, transitionProperty, mirror, mirrorElArray }: Props): RefObject<TransitionEndData>;
8
+ export declare function useTransitionEndData({ elArray, transitionProperty, secondElArray }: Props): RefObject<TransitionEndData>;
10
9
  export {};
@@ -1,18 +1,17 @@
1
1
  "use client";
2
2
  import { useEffect, useRef } from "react";
3
- export function useTransitionEndData({ elArray, transitionProperty, mirror, mirrorElArray }) {
3
+ export function useTransitionEndData({ elArray, transitionProperty, secondElArray }) {
4
4
  const transitionEndData = useRef({
5
5
  elArray: [],
6
6
  transitionProperty,
7
- mirror,
8
- mirrorElArray: [],
7
+ secondElArray: [],
9
8
  });
10
9
  useEffect(() => {
11
10
  transitionEndData.current = {
12
11
  ...transitionEndData.current,
13
12
  elArray: Array.isArray(elArray.current) ?
14
13
  elArray.current : [elArray.current],
15
- mirrorElArray: mirrorElArray.current
14
+ secondElArray: secondElArray.current
16
15
  };
17
16
  }, []);
18
17
  return transitionEndData;
@@ -3,8 +3,7 @@ export function useTransitionEndObj({ transitionEndData, fn }) {
3
3
  const transitionEndObj = useRef({
4
4
  elArray: [],
5
5
  transitionProperty: transitionEndData.current.transitionProperty,
6
- mirror: transitionEndData.current.mirror,
7
- mirrorElArray: [],
6
+ secondElArray: [],
8
7
  fn: null
9
8
  });
10
9
  useEffect(() => {
@@ -1,14 +1,12 @@
1
1
  export interface TransitionEndData {
2
2
  elArray: (HTMLDivElement | null)[];
3
3
  transitionProperty: 'opacity' | 'clip-path';
4
- mirror: boolean;
5
- mirrorElArray: (HTMLDivElement | null)[];
4
+ secondElArray: (HTMLDivElement | null)[];
6
5
  }
7
6
  export interface TransitionEndObj {
8
7
  elArray: (HTMLDivElement | null)[];
9
8
  transitionProperty: 'opacity' | 'clip-path';
10
- mirror: boolean;
11
- mirrorElArray: (HTMLDivElement | null)[];
9
+ secondElArray: (HTMLDivElement | null)[];
12
10
  fn: (() => void) | null;
13
11
  }
14
12
  export interface TransitionEndHandler {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "page-transition",
3
- "version": "0.1.0-beta.42",
3
+ "version": "0.1.0-beta.44",
4
4
  "description": "A page transition library for the Next.js App Router.",
5
5
  "license": "MIT",
6
6
  "files": [