gpt4 book ai didi

javascript - jQuery swipeleft 和 swiperight

转载 作者:行者123 更新时间:2023-11-30 00:12:13 25 4
gpt4 key购买 nike

所以我有一个小 slider 框,您可以滑动向前和向后箭头来滚动浏览内容。但是我想给它添加滑动功能,这是我第一次弄乱任何滑动的东西所以我有点迷茫,下面是我正在玩的代码;

//script for sliders

var currentlyAnimating = false;

$('.box-left').click(slideleft);
$( ".r-wide-box" ).on( "swipeleft", slideleft);

$('.box-right, .phone-next-serv').click(slideright);
$( ".r-wide-box" ).on( "swiperight", slideright);

function slideleft ( ){
var width = $(".wide-box > .row-fluid-wrapper").width();
if (currentlyAnimating) {
return;
}

currentlyAnimating = true;
$('.wide-box > .row-fluid-wrapper:last').prependTo('.wide-box');
$('.wide-box').css('left', -width);

$('.wide-box').animate({
left: '0px'
}, 500, 'linear', function() {
$('.wide-box').css('left', '0px');

currentlyAnimating = false;
});

}


function slideright ( ){
var width = $(".wide-box > .row-fluid-wrapper").width();
if (currentlyAnimating) {
return;
}

currentlyAnimating = true;

$('.wide-box').animate({
left: -width
}, 500, 'linear', function() {
$('.wide-box').css('left', '0px');
$('.wide-box > .row-fluid-wrapper:first').appendTo('.wide-box');
currentlyAnimating = false;
});


};

最佳答案

只需要添加jquery库

<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

关于javascript - jQuery swipeleft 和 swiperight,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35997016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com