Carousel for mobile using Hammerjs.
- Javascript
- Hammerjs (http://hammerjs.github.io)
- ReactJs
npm install carousel-mobile
Add to the project this files:
- carousel-mobile\
- ... carousel-mobile.jsx
- ... carousel-mobile.scss
- ... hammer-carousel.jsx
Then in your component where you want to insert it add:
const Carousel = require('../../carousel-mobile/carousel-mobile.jsx');
...
onSelect(index) {
const itemSelected = imageUrls[index];
},
render() {
const data = imageUrls.map(image => (<img src={image} />));
return (<Carousel data={data} onSelect={this.onSelect}>);
}
- data, Array of react components to be display in the carousel.
- onSelect, function that will be called when the user selects an element of the carousel. It will pass the index corresponding to the component index in the data Array.
Open it in a mobile or in the browser selecting mobile view: https://jsfiddle.net/lnolazco/yeuavao6/15/embedded/result/
No written yet. But I will use mocha for unit testing and nightwatch for functional tests.