Skip to content

Commit 71f9ab4

Browse files
committed
Expose animationDuration in propTypes. Fix indentation
1 parent 6e005f3 commit 71f9ab4

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

dist/LineChart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function(){
9797
if(!_this.props.showDataPoint)return null;
9898
return (
9999
_react2.default.createElement(Surface,{width:containerWidth,height:containerHeight,__source:{fileName:_jsxFileName,lineNumber:99}},
100-
dataPoints.map(function(d,i){return _react2.default.createElement(_Circle2.default,_extends({key:i},d,{__source:{fileName:_jsxFileName,lineNumber:100}}));})));}()));};var heightValue=props.animated?0:props.containerHeight;var opacityValue=props.animated?0:1;_this.state={height:new _reactNative.Animated.Value(heightValue),opacity:new _reactNative.Animated.Value(opacityValue)};return _this;}_createClass(LineChart,[{key:'componentWillUpdate',value:function componentWillUpdate(){if(props.animated){_reactNative.Animated.timing(this.state.opacity,{duration:0,toValue:0}).start();_reactNative.Animated.timing(this.state.height,{duration:0,toValue:0}).start();}}},{key:'componentDidUpdate',value:function componentDidUpdate(){if(props.animated){_reactNative.Animated.timing(this.state.height,{duration:this.props.animationDuration,toValue:1}).start();_reactNative.Animated.timing(this.state.opacity,{duration:this.props.animationDuration,toValue:1}).start();}}},{key:'render',value:function render()
100+
dataPoints.map(function(d,i){return _react2.default.createElement(_Circle2.default,_extends({key:i},d,{__source:{fileName:_jsxFileName,lineNumber:100}}));})));}()));};var heightValue=props.animated?0:props.containerHeight;var opacityValue=props.animated?0:1;_this.state={height:new _reactNative.Animated.Value(heightValue),opacity:new _reactNative.Animated.Value(opacityValue)};return _this;}_createClass(LineChart,[{key:'componentWillUpdate',value:function componentWillUpdate(){if(this.props.animated){_reactNative.Animated.timing(this.state.opacity,{duration:0,toValue:0}).start();_reactNative.Animated.timing(this.state.height,{duration:0,toValue:0}).start();}}},{key:'componentDidUpdate',value:function componentDidUpdate(){if(this.props.animated){_reactNative.Animated.timing(this.state.height,{duration:this.props.animationDuration,toValue:1}).start();_reactNative.Animated.timing(this.state.opacity,{duration:this.props.animationDuration,toValue:1}).start();}}},{key:'render',value:function render()
101101

102102

103103

src/Chart.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ export default class Chart extends Component<void, any, any> {
200200
onLayout={this._onContainerLayout}
201201
style={[this.props.style || {}, styles.default]}
202202
>
203-
<ChartType
203+
<ChartType
204204
{...this.props}
205205
data={this.props.data}
206-
width={this.state.containerWidth - this.props.yAxisWidth}
207-
height={this.state.containerHeight - this.props.xAxisHeight}
206+
width={this.state.containerWidth}
207+
height={this.state.containerHeight}
208208
minVerticalBound={this.state.bounds.min}
209209
maxVerticalBound={this.state.bounds.max}
210-
/>
210+
/>
211211
</View>
212212
);
213213
})()}
@@ -242,7 +242,7 @@ Chart.propTypes = {
242242
// Pie chart props
243243
// pieCenterRatio: PropTypes.number, // TODO
244244
sliceColors: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
245-
// animationDuration: PropTypes.number, // TODO
245+
animationDuration: PropTypes.number,
246246
axisColor: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
247247
axisLabelColor: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
248248
axisLineWidth: PropTypes.number,

src/LineChart.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ export default class LineChart extends Component<void, any, any> {
2020

2121
constructor(props : any) {
2222
super(props);
23-
const heightValue = (props.animated) ? 0 : props.containerHeight;
24-
const opacityValue = (props.animated) ? 0 : 1;
23+
const heightValue = (props.animated) ? 0 : props.containerHeight;
24+
const opacityValue = (props.animated) ? 0 : 1;
2525
this.state = { height: new Animated.Value(heightValue), opacity: new Animated.Value(opacityValue) };
2626
}
2727

2828
componentWillUpdate() {
29-
if (this.props.animated) {
30-
Animated.timing(this.state.opacity, { duration: 0, toValue: 0 }).start();
31-
Animated.timing(this.state.height, { duration: 0, toValue: 0 }).start();
32-
}
29+
if (this.props.animated) {
30+
Animated.timing(this.state.opacity, { duration: 0, toValue: 0 }).start();
31+
Animated.timing(this.state.height, { duration: 0, toValue: 0 }).start();
32+
}
3333
}
3434

3535
componentDidUpdate() {
36-
if (this.props.animated) {
37-
Animated.timing(this.state.height, { duration: this.props.animationDuration, toValue: 1 }).start();
38-
Animated.timing(this.state.opacity, { duration: this.props.animationDuration, toValue: 1 }).start();
39-
}
36+
if (this.props.animated) {
37+
Animated.timing(this.state.height, { duration: this.props.animationDuration, toValue: 1 }).start();
38+
Animated.timing(this.state.opacity, { duration: this.props.animationDuration, toValue: 1 }).start();
39+
}
4040
}
4141

4242
_drawLine = () => {

0 commit comments

Comments
 (0)