-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathsingle-animation.spec.js
48 lines (42 loc) · 1.17 KB
/
single-animation.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint no-console:0, react/no-multi-comp:0 */
import React from 'react';
import $ from 'jquery';
import Animate from '../index';
import './index.spec.css';
import single from './single-common.spec';
function createClass(options) {
return class extends React.Component {
state = {
transitionEnter: options.transitionEnter,
transitionAppear: options.transitionAppear,
}
fake = (type, node, done) => {
if (type === 'appear' || type === 'enter') {
node.style.display = 'none';
$(node).fadeIn(500, done);
} else {
$(node).fadeOut(500, done);
}
return {
stop() {
$(node).stop(1, 1);
},
};
}
render() {
return (
<Animate
animation={{
enter: this.fake.bind(this, 'enter'),
appear: this.state.transitionAppear ? this.fake.bind(this, 'appear') : null,
leave: this.fake.bind(this, 'leave'),
}}
component={options.component}
>
{options.remove && !this.state.transitionEnter ? null : <div key="1">child element</div>}
</Animate>
);
}
};
}
single(createClass, 'animation');