1 | import { FC, ReactNode } from 'react' |
||
2 | import { SwitchTransition, CSSTransition } from 'react-transition-group' |
||
3 | |||
4 | interface IProps { |
||
5 | mode?: 'out-in' | 'in-out' |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
6 | classNames: string |
||
7 | keyProp: number | string |
||
8 | timeout: number |
||
9 | children: ReactNode |
||
10 | } |
||
11 | |||
12 | const PageChangeAnimation: FC<IProps> = ({ |
||
0 ignored issues
–
show
|
|||
13 | children, |
||
14 | classNames, |
||
15 | keyProp, |
||
16 | mode = 'out-in', |
||
17 | timeout, |
||
18 | }) => ( |
||
19 | <SwitchTransition mode={mode}> |
||
0 ignored issues
–
show
|
|||
20 | <CSSTransition |
||
0 ignored issues
–
show
|
|||
21 | key={keyProp} |
||
0 ignored issues
–
show
|
|||
22 | onExited={() => |
||
0 ignored issues
–
show
|
|||
23 | setTimeout( |
||
24 | () => |
||
25 | window.scrollTo({ |
||
26 | top: 0, |
||
27 | behavior: 'smooth', |
||
28 | }), |
||
29 | 420, |
||
30 | ) |
||
31 | } |
||
0 ignored issues
–
show
|
|||
32 | timeout={timeout} |
||
0 ignored issues
–
show
|
|||
33 | classNames={classNames} |
||
0 ignored issues
–
show
|
|||
34 | > |
||
35 | {children} |
||
0 ignored issues
–
show
|
|||
36 | </CSSTransition> |
||
37 | </SwitchTransition> |
||
38 | ) |
||
39 | |||
40 | export { PageChangeAnimation } |
||
41 |