|
1 |
| -import { withHandlers, isolate, onWillReceiveProps, onWillUnmount } from "reassemble"; |
| 1 | +import { withHandlers, isolate, onWillReceiveProps, onDidUpdate, onWillUnmount } from "reassemble"; |
2 | 2 |
|
3 | 3 | import { CSSTransitionProps } from "../csstransition";
|
4 | 4 | import { WithTransitionStateProps } from "./withTransitionState";
|
@@ -28,18 +28,31 @@ export const withTimeout =
|
28 | 28 | };
|
29 | 29 | }),
|
30 | 30 | onWillReceiveProps<PropsUnion>(
|
| 31 | + ( |
| 32 | + {transitionState: {inTransition}, active}, |
| 33 | + { |
| 34 | + transitionState: {inTransition: nextInTransition}, |
| 35 | + cancel, active: nextActive, |
| 36 | + }, |
| 37 | + ) => { |
| 38 | + const inTransitionChanged = inTransition !== nextInTransition; |
| 39 | + const interrupted = nextInTransition && active !== nextActive; |
| 40 | + if (inTransitionChanged || interrupted) { |
| 41 | + cancel(); |
| 42 | + } |
| 43 | + }), |
| 44 | + onDidUpdate<PropsUnion>( |
31 | 45 | (
|
32 | 46 | {transitionState: {inTransition}, active},
|
33 | 47 | {
|
34 | 48 | transitionState: {inTransition: nextInTransition},
|
35 | 49 | transitionInfo: {totalDuration},
|
36 |
| - cancel, timeoutIn, active: nextActive, |
| 50 | + timeoutIn, active: nextActive, |
37 | 51 | },
|
38 | 52 | ) => {
|
39 |
| - const newTransition = inTransition !== nextInTransition; |
| 53 | + const newTransition = !inTransition && nextInTransition; |
40 | 54 | const interrupted = nextInTransition && active !== nextActive;
|
41 | 55 | if (newTransition || interrupted) {
|
42 |
| - cancel(); |
43 | 56 | if (nextInTransition) {
|
44 | 57 | timeoutIn(totalDuration * timeoutMultiplier);
|
45 | 58 | }
|
|
0 commit comments