|
@@ -71,10 +71,10 @@ export default class PhotoSlider extends React.Component<
|
|
|
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
super(props);
|
|
super(props);
|
|
- const { index = 0 } = props;
|
|
|
|
|
|
+
|
|
this.state = {
|
|
this.state = {
|
|
- translateX: index * -(window.innerWidth + horizontalOffset),
|
|
|
|
- photoIndex: index,
|
|
|
|
|
|
+ translateX: 0,
|
|
|
|
+ photoIndex: 0,
|
|
touched: false,
|
|
touched: false,
|
|
|
|
|
|
lastPageX: undefined,
|
|
lastPageX: undefined,
|
|
@@ -85,6 +85,11 @@ export default class PhotoSlider extends React.Component<
|
|
}
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
|
|
+ const { index = 0 } = this.props;
|
|
|
|
+ this.setState({
|
|
|
|
+ translateX: index * -(window.innerWidth + horizontalOffset),
|
|
|
|
+ photoIndex: index,
|
|
|
|
+ });
|
|
window.addEventListener('resize', this.handleResize);
|
|
window.addEventListener('resize', this.handleResize);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -187,7 +192,6 @@ export default class PhotoSlider extends React.Component<
|
|
}
|
|
}
|
|
|
|
|
|
render() {
|
|
render() {
|
|
- const { innerWidth } = window;
|
|
|
|
const {
|
|
const {
|
|
images,
|
|
images,
|
|
visible,
|
|
visible,
|
|
@@ -210,6 +214,8 @@ export default class PhotoSlider extends React.Component<
|
|
const transform = `translate3d(${translateX}px, 0px, 0)`;
|
|
const transform = `translate3d(${translateX}px, 0px, 0)`;
|
|
|
|
|
|
if (visible) {
|
|
if (visible) {
|
|
|
|
+ const { innerWidth } = window;
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<SlideWrap className={className}>
|
|
<SlideWrap className={className}>
|
|
<Backdrop
|
|
<Backdrop
|