2015-10-28 17:22:14 +01:00
|
|
|
/* jshint node: true */
|
2015-10-20 13:15:27 +02:00
|
|
|
var React = require('react');
|
|
|
|
var AnimateMixin = require('../mixins/animate');
|
2015-10-28 17:22:14 +01:00
|
|
|
var ReactCSSTransitionGroup = require('react-addons-css-transition-group');
|
2015-10-20 13:15:27 +02:00
|
|
|
|
|
|
|
module.exports = React.createClass({
|
|
|
|
|
|
|
|
mixins: [AnimateMixin],
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
src: React.PropTypes.string
|
|
|
|
},
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return { currSrc: null, prevSrc: null };
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillReceiveProps: function(nextProps) {
|
|
|
|
this.setState({ currSrc: nextProps.src, prevSrc: this.state.currSrc });
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
|
2015-10-28 17:22:14 +01:00
|
|
|
var topStyle = {
|
2015-10-20 13:15:27 +02:00
|
|
|
backgroundImage: 'url('+this.state.currSrc+')'
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="crossfade-image">
|
2015-10-28 17:22:14 +01:00
|
|
|
<ReactCSSTransitionGroup transitionName="crossfade" transitionLeaveTimeout={2000}>
|
|
|
|
<div key={this.state.currSrc} className="top" style={topStyle}></div>
|
|
|
|
</ReactCSSTransitionGroup>
|
2015-10-20 13:15:27 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|