Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery滑块不会在mousedown和mouseup的作用下瞬间停止_Jquery_Jquery Slider - Fatal编程技术网

jquery滑块不会在mousedown和mouseup的作用下瞬间停止

jquery滑块不会在mousedown和mouseup的作用下瞬间停止,jquery,jquery-slider,Jquery,Jquery Slider,下面的链接是用于复制jquery滑块的,我想使滑动平滑,但当我在setinterval(比如200)中缩短时间时,滑块不会立即响应mouseup事件,并且在触发mouseup后一两秒钟幻灯片停止。 我还尝试在jquery动画上使用stop,但这没有帮助。 这里是链接。 现在,幻灯片每半秒移动10像素,我想让它看起来平滑 $("#popUpInnerArrowLeft").mousedown(function (event) { movetoleft(); }); var into,

下面的链接是用于复制jquery滑块的,我想使滑动平滑,但当我在setinterval(比如200)中缩短时间时,滑块不会立即响应mouseup事件,并且在触发mouseup后一两秒钟幻灯片停止。 我还尝试在jquery动画上使用stop,但这没有帮助。 这里是链接。 现在,幻灯片每半秒移动10像素,我想让它看起来平滑

$("#popUpInnerArrowLeft").mousedown(function (event) {

    movetoleft();
});

var into, into2;

function movetoleft() {
    function moveit() {
        $(".thumbsInnerContainer").animate({
            left: '-=10px'
        });
    }

    into = setInterval(function () {
        moveit();
    }, 500);

}

$(document).mouseup(function (event) {
    clearInterval(into);

});



//for the right arrow

$("#popUpInnerArrowRight").mousedown(function (event) {
    movetoright();
});

function movetoright() {

    function moveit2() {
        $(".thumbsInnerContainer").animate({
            left: '+=10px'
        });
    }

    into2 = setInterval(function () {
        moveit2();
    }, 500);

}

$(document).mouseup(function (event) {
    clearInterval(into2);
});
选中此项(这是您想要的):

在这里演奏小提琴:

var into, into2, unit = '';

$("#popUpInnerArrowLeft").click(function (e) {  
    e.preventDefault();
    unit = false;
    movetoleft();
});

//for the right arrow
$("#popUpInnerArrowRight").click(function (e) {
    e.preventDefault();
    unit = true;
    movetoright();
});

function moveit() {    

    $(".thumbsInnerContainer").stop(true,true).animate({
        left: ((unit == true)? '+=':'-=') + '10px'
    },{easing:'linear'});
}

function movetoright() {        
    into = setInterval(function () {
        moveit();
    }, 300);
}

function movetoleft() {    
    into = setInterval(function () {
        moveit();
    }, 300);
}

$(document).mouseup(function (event) {
    clearInterval(into);    
});