page-transition 0.1.0-beta.51 → 0.1.0-beta.52

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
@@ -10,7 +10,7 @@ A page transition library for the Next.js App Router.
10
10
  - Scroll restoration
11
11
 
12
12
  ## Install
13
- ![Version](https://img.shields.io/badge/v_0.1.0--beta.48-000000) ![68.3 KB](https://img.shields.io/badge/68.3_KB-1677FF)
13
+ ![Version](https://img.shields.io/badge/v_0.1.0--beta.51-000000) ![68.3 KB](https://img.shields.io/badge/68.3_KB-1677FF)
14
14
 
15
15
  `npm install page-transition@beta`
16
16
 
@@ -42,7 +42,7 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
42
42
  |Prop|Type|Default|Mode|
43
43
  |---|---|---|---|
44
44
  | mode | "css" \| "manual" | "css" | Both |
45
- | header | JSX | - | CSS |
45
+ | outside | JSX | - | CSS |
46
46
  | options | *Options* | {} | CSS |
47
47
 
48
48
  *Options*
@@ -58,8 +58,8 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
58
58
  **mode**
59
59
  Select the transition mode.
60
60
 
61
- **header**
62
- The component rendered outside the .page-wrapper.
61
+ **outside**
62
+ Components rendered outside .page-wrapper, but still inside the transition container.
63
63
 
64
64
  **options.transitionProperty**
65
65
  Defines which property transitionend waits for.
@@ -75,7 +75,7 @@ Number of items in the second group. Each item receives the `.second-item` class
75
75
 
76
76
  ```tsx
77
77
  <TransitionProvider
78
- header={<Header/>}
78
+ outside={<Header/>}
79
79
  options={{
80
80
  transitionProperty: "clip-path",
81
81
  items: [1, 0]
@@ -114,6 +114,22 @@ Triggers the transition.
114
114
 
115
115
  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. By default, this is the `.page-wrapper` containing the page's children. If options.items is configured, the event is instead tracked on the last item of the first group.
116
116
 
117
+ ```tsx
118
+ <div data-transition>
119
+ {outside}
120
+ {
121
+ (options.items[0] > 0 || options.items[1] > 0) &&
122
+ <div className="overlay-wrapper">
123
+ ...
124
+ </div>
125
+ }
126
+ <div className={"page-wrapper"}>
127
+ {children}
128
+ </div>
129
+ </div>
130
+
131
+ ```
132
+
117
133
  Once the transition ends, the scroll position is restored and navigation is performed.
118
134
 
119
135
  After navigation, the `exit` class is removed and the `enter` class is added. Once the next transitionend event fires, the enter class is removed.
@@ -5,9 +5,9 @@ interface TransitionOptions {
5
5
  items?: [number, number];
6
6
  }
7
7
  interface ProviderProps {
8
- header?: ReactNode;
8
+ outside?: ReactNode;
9
9
  options: TransitionOptions;
10
10
  children: ReactNode;
11
11
  }
12
- export declare function CssTransitionProvider({ header, options, children }: ProviderProps): import("react").JSX.Element;
12
+ export declare function CssTransitionProvider({ outside, options, children }: ProviderProps): import("react").JSX.Element;
13
13
  export {};
@@ -11,7 +11,7 @@ import { useHandleLinkClick } from "../hooks/useHandleLinkClick";
11
11
  import { useScrollRestoration } from "../hooks/useScrollRestoration";
12
12
  import { usePopState } from "../hooks/usePopState";
13
13
  import { pollTransitionStart } from "../functions/pollTransitionStart";
14
- export function CssTransitionProvider({ header, options, children }) {
14
+ export function CssTransitionProvider({ outside, options, children }) {
15
15
  const defaultOptions = {
16
16
  items: [0, 0],
17
17
  ...options
@@ -95,9 +95,10 @@ export function CssTransitionProvider({ header, options, children }) {
95
95
  currentPathname.current = window.location.pathname;
96
96
  }, [pathname]);
97
97
  const value = useMemo(() => ({ handleLinkClick, overlayWrapper, overlayItems }), []);
98
- return (_jsx(TransitionContext.Provider, { value: value, children: _jsxs("div", { ref: container, "data-transition": true, children: [header, _jsxs("div", { ref: overlayWrapper, className: "overlay-wrapper", children: [defaultOptions.items[0] > 0 && Array.from({ length: defaultOptions.items[0] }).map((_, i) => (_jsx("div", { ref: (el) => {
99
- overlayItems.current[i] = el;
100
- }, className: "overlay-item" }, i))), defaultOptions.items[1] > 0 && Array.from({ length: defaultOptions.items[1] }).map((_, i) => (_jsx("div", { ref: (el) => {
101
- secondItems.current[i] = el;
102
- }, className: "second-item" }, `mirror${i}`)))] }), _jsx("div", { ref: pageWrapper, className: "page-wrapper", children: children })] }) }));
98
+ return (_jsx(TransitionContext.Provider, { value: value, children: _jsxs("div", { ref: container, "data-transition": true, children: [outside, (defaultOptions.items[0] > 0 || defaultOptions.items[1] > 0) &&
99
+ _jsxs("div", { ref: overlayWrapper, className: "overlay-wrapper", children: [defaultOptions.items[0] > 0 && Array.from({ length: defaultOptions.items[0] }).map((_, i) => (_jsx("div", { ref: (el) => {
100
+ overlayItems.current[i] = el;
101
+ }, className: "overlay-item" }, i))), defaultOptions.items[1] > 0 && Array.from({ length: defaultOptions.items[1] }).map((_, i) => (_jsx("div", { ref: (el) => {
102
+ secondItems.current[i] = el;
103
+ }, className: "second-item" }, `mirror${i}`)))] }), _jsx("div", { ref: pageWrapper, className: "page-wrapper", children: children })] }) }));
103
104
  }
@@ -15,10 +15,10 @@ interface TransitionOptions {
15
15
  items?: [number, number];
16
16
  }
17
17
  interface ProviderProps {
18
- header?: ReactNode;
18
+ outside?: ReactNode;
19
19
  mode?: Mode;
20
20
  options: TransitionOptions;
21
21
  children: ReactNode;
22
22
  }
23
- export declare function TransitionProvider({ header, mode, options, children }: ProviderProps): import("react").JSX.Element;
23
+ export declare function TransitionProvider({ outside, mode, options, children }: ProviderProps): import("react").JSX.Element;
24
24
  export {};
@@ -10,8 +10,8 @@ export function useTransitionContext() {
10
10
  throw new Error('useTransitionContext in Provider!');
11
11
  return context;
12
12
  }
13
- export function TransitionProvider({ header, mode = 'css', options, children }) {
13
+ export function TransitionProvider({ outside, mode = 'css', options, children }) {
14
14
  return (mode === 'css' ?
15
- _jsx(CssTransitionProvider, { header: header, options: options, children: children }) :
15
+ _jsx(CssTransitionProvider, { outside: outside, options: options, children: children }) :
16
16
  _jsx(ManualTransitionProvider, { children: children }));
17
17
  }
@@ -73,7 +73,6 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
73
73
  new Promise((resolve) => {
74
74
  if (state.current === 'navigating') {
75
75
  if (basePathUrl === currentPathname.current) {
76
- afterExitFn.current?.();
77
76
  return;
78
77
  }
79
78
  else if (basePathUrl !== currentPathname.current) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "page-transition",
3
- "version": "0.1.0-beta.51",
3
+ "version": "0.1.0-beta.52",
4
4
  "description": "A page transition library for the Next.js App Router.",
5
5
  "license": "MIT",
6
6
  "files": [