react-crossfade-image
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -49,3 +49,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
return _this2.setState({ bottomOpacity: 0 }); | ||
}, 10); | ||
}, 20); | ||
}); | ||
@@ -52,0 +52,0 @@ }); |
32
index.js
@@ -1,7 +0,7 @@ | ||
import React, { Component } from "react"; | ||
import PropTypes from "prop-types"; | ||
import React, { Component } from "react" | ||
import PropTypes from "prop-types" | ||
export default class CrossfadeImage extends Component { | ||
constructor(props) { | ||
super(props); | ||
super(props) | ||
this.state = { | ||
@@ -11,7 +11,7 @@ topSrc: props.src, | ||
bottomSrc: props.src | ||
}; | ||
} | ||
} | ||
componentWillReceiveProps(newProps) { | ||
const oldSrc = this.state.topSrc; | ||
const newSrc = newProps.src; | ||
const oldSrc = this.state.topSrc | ||
const newSrc = newProps.src | ||
if (newSrc !== oldSrc) { | ||
@@ -27,15 +27,15 @@ // Reset the component everytime we receive new prop, to | ||
// getting fade out transition without css keyframe | ||
if (!this.timeout) clearTimeout(this.timeout); | ||
if (!this.timeout) clearTimeout(this.timeout) | ||
this.timeout = setTimeout( | ||
() => this.setState({ bottomOpacity: 0 }), | ||
10 | ||
); | ||
20 | ||
) | ||
} | ||
) | ||
); | ||
) | ||
} | ||
} | ||
render() { | ||
const { duration, timingFunction, delay, style } = this.props; | ||
const { topSrc, bottomOpacity, bottomSrc } = this.state; | ||
const { duration, timingFunction, delay, style } = this.props | ||
const { topSrc, bottomOpacity, bottomSrc } = this.state | ||
return ( | ||
@@ -61,7 +61,7 @@ <div style={{ ...defaultStyle, ...{ position: "relative" } }}> | ||
</div> | ||
); | ||
) | ||
} | ||
} | ||
const defaultStyle = { maxWidth: "100%", maxHeight: "100%" }; | ||
const defaultStyle = { maxWidth: "100%", maxHeight: "100%" } | ||
@@ -74,3 +74,3 @@ CrossfadeImage.propTypes = { | ||
style: PropTypes.object | ||
}; | ||
} | ||
@@ -81,2 +81,2 @@ CrossfadeImage.defaultProps = { | ||
delay: 0 | ||
}; | ||
} |
{ | ||
"name": "react-crossfade-image", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Simple React component for crossfading images", | ||
@@ -34,2 +34,3 @@ "main": "index.es5.js", | ||
"babel-preset-stage-0": "^6.24.1", | ||
"react-dom": "^15.5.4", | ||
"rimraf": "^2.6.1", | ||
@@ -36,0 +37,0 @@ "webpack": "^2.5.1", |
@@ -7,3 +7,8 @@ # react-crossfade-image | ||
```javascript | ||
npm install react-crossfade-image | ||
``` | ||
Clone and run `npm start` for demo. | ||
Sample component: | ||
@@ -19,4 +24,2 @@ ```javascript | ||
Clone and run `npm start` for demo. | ||
## Props | ||
@@ -23,0 +26,0 @@ |
129959
43
10