page-transition 0.1.0-beta.59 → 0.1.0-beta.60
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 +12 -12
- package/dist/components/css/TransitionLink.js +2 -2
- package/dist/components/manual/TransitionLink.js +2 -2
- package/dist/context/CssContext.d.ts +1 -1
- package/dist/context/CssContext.js +1 -1
- package/dist/context/ManualContext.d.ts +1 -1
- package/dist/context/ManualContext.js +1 -1
- package/dist/css.d.ts +1 -0
- package/dist/css.js +2 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/manual.d.ts +1 -0
- package/dist/manual.js +2 -0
- package/package.json +1 -1
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
|
-
 
|
|
14
14
|
|
|
15
15
|
`npm install page-transition@beta`
|
|
16
16
|
|
|
@@ -86,8 +86,9 @@ Number of items in the second group. Each item receives the `.second-item` class
|
|
|
86
86
|
<TransitionProvider
|
|
87
87
|
outside={<Header/>}
|
|
88
88
|
options={{
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
overlay: true,
|
|
90
|
+
transitionProperty: "clip-path",
|
|
91
|
+
items: [1, 0]
|
|
91
92
|
}}
|
|
92
93
|
>
|
|
93
94
|
{children}
|
|
@@ -113,12 +114,12 @@ Triggers the transition.
|
|
|
113
114
|
|
|
114
115
|
*Must be used within the TransitionProvider*
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
css
|
|
117
118
|
```tsx
|
|
118
119
|
import {TransitionLink} from "page-transition/css"
|
|
119
120
|
|
|
120
121
|
```
|
|
121
|
-
|
|
122
|
+
manual
|
|
122
123
|
```tsx
|
|
123
124
|
import {TransitionLink} from "page-transition/manual"
|
|
124
125
|
```
|
|
@@ -165,9 +166,9 @@ After navigation, the `exit` class is removed and the `enter` class is added. On
|
|
|
165
166
|
```
|
|
166
167
|
|
|
167
168
|
|
|
168
|
-
To access the page wrapper, overlay, overlay wrapper, and their respective items, use `
|
|
169
|
+
To access the page wrapper, overlay, overlay wrapper, and their respective items, use `useTransitionContext`.
|
|
169
170
|
```ts
|
|
170
|
-
import {
|
|
171
|
+
import { useTransitionContext } from "page-transition/css"
|
|
171
172
|
|
|
172
173
|
const {
|
|
173
174
|
pageWrapper,
|
|
@@ -213,7 +214,7 @@ overlay: true
|
|
|
213
214
|
</details>
|
|
214
215
|
|
|
215
216
|
<details>
|
|
216
|
-
<summary>Single Overlay</summary>
|
|
217
|
+
<summary>Single Overlay and Opacity</summary>
|
|
217
218
|
<br/>
|
|
218
219
|
options
|
|
219
220
|
|
|
@@ -394,10 +395,9 @@ items: [10, 10]
|
|
|
394
395
|
</details>
|
|
395
396
|
|
|
396
397
|
|
|
397
|
-
|
|
398
398
|
### Manual Mode
|
|
399
399
|
|
|
400
|
-
In manual mode, you can control the transition using `
|
|
400
|
+
In manual mode, you can control the transition using `useTransitionContext`.
|
|
401
401
|
|
|
402
402
|
|
|
403
403
|
After triggering the navigation, `state.current` is set to `exiting`. You can then call `resolveFn.current()` to proceed with the navigation.
|
|
@@ -408,8 +408,8 @@ Once `state.current` is set to `entering`, the navigation has occurred. After th
|
|
|
408
408
|
|
|
409
409
|
|
|
410
410
|
```ts
|
|
411
|
-
import {
|
|
411
|
+
import { useTransitionContext } from "page-transition/manual"
|
|
412
412
|
|
|
413
|
-
const { resolveFn, state } =
|
|
413
|
+
const { resolveFn, state } = useTransitionContext()
|
|
414
414
|
|
|
415
415
|
```
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Link from "next/link";
|
|
3
|
-
import {
|
|
3
|
+
import { useTransitionContext } from "../../context/CssContext";
|
|
4
4
|
export function TransitionLink({ href, className, prefetch, onClick, children }) {
|
|
5
|
-
const { handleLinkClick } =
|
|
5
|
+
const { handleLinkClick } = useTransitionContext();
|
|
6
6
|
return (_jsx(Link, { href: href, onClick: (e) => {
|
|
7
7
|
onClick?.(e);
|
|
8
8
|
handleLinkClick.current(e, href);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Link from "next/link";
|
|
3
|
-
import {
|
|
3
|
+
import { useTransitionContext } from "../../context/ManualContext";
|
|
4
4
|
export function TransitionLink({ href, className, prefetch, onClick, children }) {
|
|
5
|
-
const { handleLinkClick } =
|
|
5
|
+
const { handleLinkClick } = useTransitionContext();
|
|
6
6
|
return (_jsx(Link, { href: href, onClick: (e) => {
|
|
7
7
|
onClick?.(e);
|
|
8
8
|
handleLinkClick.current(e, href);
|
|
@@ -8,5 +8,5 @@ interface ContextProps {
|
|
|
8
8
|
secondItems?: RefObject<(HTMLDivElement | null)[]>;
|
|
9
9
|
}
|
|
10
10
|
export declare const CssContext: import("react").Context<ContextProps | null>;
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function useTransitionContext(): ContextProps;
|
|
12
12
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
export const CssContext = createContext(null);
|
|
4
|
-
export function
|
|
4
|
+
export function useTransitionContext() {
|
|
5
5
|
const context = useContext(CssContext);
|
|
6
6
|
if (!context)
|
|
7
7
|
throw new Error('useCssContext in Provider!');
|
|
@@ -5,5 +5,5 @@ interface ContextProps {
|
|
|
5
5
|
state?: RefObject<'idle' | 'exiting' | 'entering'>;
|
|
6
6
|
}
|
|
7
7
|
export declare const ManualContext: import("react").Context<ContextProps | null>;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function useTransitionContext(): ContextProps;
|
|
9
9
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
export const ManualContext = createContext(null);
|
|
4
|
-
export function
|
|
4
|
+
export function useTransitionContext() {
|
|
5
5
|
const context = useContext(ManualContext);
|
|
6
6
|
if (!context)
|
|
7
7
|
throw new Error('useManualContext in Provider!');
|
package/dist/css.d.ts
CHANGED
package/dist/css.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/manual.d.ts
CHANGED
package/dist/manual.js
CHANGED