Skip to content

Commit f43716e

Browse files
committed
rever to simple animation
1 parent 671c83a commit f43716e

File tree

2 files changed

+9
-78
lines changed

2 files changed

+9
-78
lines changed

src/SearchBox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import SearchIcon from 'material-ui/svg-icons/action/search';
66
const SearchBox = ({isOpen, additionalStyles, clickHandler}) => {
77
const baseStyles = {
88
open: {
9-
9+
width: 300,
1010
},
1111
closed: {
12-
12+
width: 0,
1313
},
1414
smallIcon: {
1515
width: 30,

src/expanding-animation.js

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,28 @@
11
import React, {Component} from 'react';
22

3-
const expandAnimationStyles = {
4-
open: {
5-
text: {
6-
transition: 'width 0.75s cubic-bezier(0.000, 0.795, 0.000, 1.000)',
7-
width: 300,
8-
},
9-
frame: {
10-
transition: 'width 0.75s cubic-bezier(0.000, 0.795, 0.000, 1.000)',
11-
width: 300,
12-
position: 'absolute',
13-
left: 0,
14-
top:-25,
15-
marginLeft: -150
16-
}
17-
},
18-
closed: {
19-
text: {
20-
transition: 'width 0.75s cubic-bezier(0.000, 0.795, 0.000, 1.000)',
21-
width: 0,
22-
},
23-
frame: {
24-
transition: 'width 0.75s cubic-bezier(0.000, 0.795, 0.000, 1.000)',
25-
width: 0,
26-
}
27-
},
28-
29-
};
30-
const translationAnimationStyles = {
31-
open: {
32-
text: {
33-
width: 0,
34-
},
35-
frame: {
36-
transform: 'translateX(-150px)',
37-
transition: 'transform 0.5s ease'
38-
}
39-
},
40-
closed: {
41-
text: {
42-
width: 0,
43-
},
44-
frame: {
45-
transition: 'transform 0.5s ease'
46-
}
47-
}
3+
const animationStyle = {
4+
transition: 'width 0.75s cubic-bezier(0.000, 0.795, 0.000, 1.000)'
485
};
496

507
const makeExpanding = (Target) => {
518
return class extends Component {
529
constructor(props) {
5310
super(props);
54-
this.state = {
55-
isOpen: false,
56-
animationStyles: [expandAnimationStyles.closed]
57-
};
11+
this.state = {isOpen: false};
5812
}
5913

6014
onClick = () => {
6115
let newState = !this.state.isOpen;
62-
let newAnimationStyles;
63-
64-
if (newState) newAnimationStyles = [translationAnimationStyles.open, expandAnimationStyles.open];
65-
else newAnimationStyles = [expandAnimationStyles.closed, translationAnimationStyles.closed];
66-
6716
this.setState({
68-
isOpen: newState,
69-
animationStyles: newAnimationStyles
17+
isOpen: newState
7018
});
7119
};
72-
handleTransitionEnd = ({target, propertyName, elapsedTime}) => {
73-
console.log(`${target.innerHTML}:${this.animationWrapper.innerHTML}`);
74-
if (propertyName === 'transform' || propertyName === 'width') {
75-
let animationStyles = this.state.animationStyles;
76-
if (animationStyles.length > 1)
77-
animationStyles.splice(0, 1);
78-
79-
this.setState({animationStyles: animationStyles});
80-
}
81-
};
8220

8321
render() {
84-
const refCallback = (animationWrapper) => {
85-
this.animationWrapper = animationWrapper;
86-
};
8722
return (
88-
<div ref={refCallback} onTransitionEnd={this.handleTransitionEnd} >
89-
<Target isOpen={this.state.isOpen}
90-
clickHandler={this.onClick}
91-
additionalStyles={this.state.animationStyles[0]}
92-
/>
93-
94-
</div>
23+
<Target isOpen={this.state.isOpen}
24+
clickHandler={this.onClick}
25+
additionalStyles={{text:animationStyle, frame:animationStyle}} />
9526
);
9627
}
9728
}

0 commit comments

Comments
 (0)