javascript - Enable swipe in Multi image Carousel for mobile -
i have multicarousel left , right arrow. want disable arrows on mobile screen , want enable swipe right or left on mobile.
this part of js using it.
$(document).ready(function () { var itemsmaindiv = ('.multicarousel'); var itemsdiv = ('.multicarousel-inner'); var itemwidth = ""; $('.leftlst, .rightlst').click(function () { var condition = $(this).hasclass("leftlst"); if (condition) click(0, this); else click(1, this) }); rescarouselsize(); $(window).resize(function () { rescarouselsize(); });
i have try enable swipe following function not working me.
$(document).ready(function() { $(".multicarousel-inner").swiperight(function() { $(this).parent().multicarousel('prev'); }); $(".multicarousel-inner").swipeleft(function() { $(this).parent().multicarousel('next'); }); });
these left , right buttons,
function rescarousel(e, el, s) { var leftbtn = ('.leftlst'); var rightbtn = ('.rightlst'); var translatexval = ''; var divstyle = $(el + ' ' + itemsdiv).css('transform'); var values = divstyle.match(/-?[\d\.]+/g); var xds = math.abs(values[4]); if (e == 0) { translatexval = parseint(xds) - parseint(itemwidth * s); $(el + ' ' + rightbtn).removeclass("over"); if (translatexval <= itemwidth / 2) { translatexval = 0; $(el + ' ' + leftbtn).addclass("over"); } } else if (e == 1) { var itemscondition = $(el).find(itemsdiv).width() - $(el).width(); translatexval = parseint(xds) + parseint(itemwidth * s); $(el + ' ' + leftbtn).removeclass("over"); if (translatexval >= itemscondition - itemwidth / 2) { translatexval = itemscondition; $(el + ' ' + rightbtn).addclass("over"); } } $(el + ' ' + itemsdiv).css('transform', 'translatex(' + -translatexval + 'px)'); }
please check , me fix this. thank you
Comments
Post a Comment