我在网页上有一些不同的div,我正在使用Hammer.js来刷这些div。我面临的问题是滑动功能一次只能在一个div上工作,有没有办法一次滑动多个div,如果只滑动div就可以同时滑动。
var element= document.getElementById('1');
var element_2= document.getElementById('2');
Hammer(element).on("swiperight",function(){
//console.log(swapID);
//console.log(numberOfTiles);
//document.getElementById( i.toString()).style.backgroundColor = 'green';
var $carousel = $('#'+1+' .swiper-wrapper'),
currentSlide, nextSlide;
currentSlide = $carousel.attr('data-slide');
nextSlide = +currentSlide === 4 ? 1 : +currentSlide +1;
$carousel.attr('data-slide', nextSlide);
});
Hammer(element_2).on("swiperight",function(){
//console.log(swapID);
//console.log(numberOfTiles);
//document.getElementById( i.toString()).style.backgroundColor = 'green';
var $carousel = $('#'+2+' .swiper-wrapper'),
currentSlide, nextSlide;
currentSlide = $carousel.attr('data-slide');
nextSlide = +currentSlide === 4 ? 1 : +currentSlide +1;
$carousel.attr('data-slide', nextSlide);
});