Skip to content
This repository was archived by the owner on Apr 14, 2020. It is now read-only.

Commit ab441ad

Browse files
committed
feat: adds TIME_TO_WAIT_FOR_NEXT_BABA prop
1 parent f7e8afc commit ab441ad

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

packages/yubaba/src/Baba/index.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ export interface BabaProps extends CollectorChildrenProps, InjectedProps {
7676
* component.
7777
*/
7878
onFinish: () => void;
79+
80+
/**
81+
* Time this component will wait until it throws away the animation.
82+
* Defaults to 50ms, might want to bump it up if loading something that was code split.
83+
*/
84+
TIME_TO_WAIT_FOR_NEXT_BABA: number;
7985
}
8086

8187
/**
@@ -117,15 +123,14 @@ export class Baba extends React.PureComponent<BabaProps, State> {
117123

118124
static defaultProps = {
119125
onFinish: noop,
126+
TIME_TO_WAIT_FOR_NEXT_BABA: 50,
120127
};
121128

122129
state: State = {
123130
shown: false,
124131
childProps: {},
125132
};
126133

127-
TIME_TO_WAIT_FOR_NEXT_BABA = 50;
128-
129134
animating: boolean = false;
130135

131136
unmounting: boolean = false;
@@ -214,9 +219,9 @@ You're switching between controlled and uncontrolled, don't do this. Either alwa
214219
}
215220

216221
delayedClearDOMData() {
217-
const { name } = this.props;
222+
const { name, TIME_TO_WAIT_FOR_NEXT_BABA } = this.props;
218223

219-
setTimeout(() => childrenStore.remove(name), this.TIME_TO_WAIT_FOR_NEXT_BABA);
224+
setTimeout(() => childrenStore.remove(name), TIME_TO_WAIT_FOR_NEXT_BABA);
220225
}
221226

222227
storeDOMData() {
@@ -421,11 +426,10 @@ If it's an image, try and have the image loaded before mounting, or set a static
421426
}
422427
};
423428

424-
const beforeAnimatePromises = actions.map(
425-
targetData =>
426-
targetData.action === CollectorActions.animation
427-
? targetData.payload.beforeAnimate()
428-
: Promise.resolve()
429+
const beforeAnimatePromises = actions.map(targetData =>
430+
targetData.action === CollectorActions.animation
431+
? targetData.payload.beforeAnimate()
432+
: Promise.resolve()
429433
);
430434

431435
Promise.all(beforeAnimatePromises)

0 commit comments

Comments
 (0)