So, I'm trying to make a gallery like this with Flickity and React, but I get some strange flickering and the animation won't start until I try to resize the (output) window, and then everything plays nicely. On Firefox, sometimes it works, sometimes it doesn't, while Chrome is refusing to cooperate completely. Maybe, it's worth mentioning that I made this work with plain Javascript and Flickity, so I guess I'm doing something wrong in React. Here's the code:
HTML:
<div id="main"></div>
ReactJS
var Gallery = React.createClass({
componentDidMount: function() {
this.flkty = new Flickity('.gallery', {
freeScroll: true,
wrapAround: true,
prevNextButtons: false,
pageDots: false,
freeScrollFriction: 0.00,
lazyLoad: 2
});
this.flkty.velocity = 1;
this.flkty.isFreeScrolling = true;
this.flkty.startAnimation();
},
render: function() {
return (
<div className="gallery">
<div key="01" className="gallery-cell">
<img src="http://placehold.it/450x1500" />
</div>
<div key="02" className="gallery-cell">
<img src="http://placehold.it/850x1200" />
</div>
<div key="03" className="gallery-cell">
<img src="http://placehold.it/150x1500" />
</div>
<div key="04" className="gallery-cell">
<img src="http://placehold.it/1850x1500" />
</div>
<div key="05" className="gallery-cell">
<img src="http://placehold.it/650x1000" />
</div>
<div key="06" className="gallery-cell">
<img src="http://placehold.it/350x2500" />
</div>
</div>
)}
});
ReactDOM.render(
<Gallery />,
document.getElementById('main')
);
SCSS:
html,
body {
height: 100%;
margin: 0;
padding: 0;
background: #833;
}
div#main {
margin: 0 auto;
width: 750px;
height: auto !important;
height: 100%;
min-height: 100%;
}
.gallery {
background: #EEE;
overflow: hidden;
}
.gallery-cell {
display: inline-block;
height: 100vh;
img {
border-left: 2px solid #444;
height: 100%;
}
}