简体   繁体   English

单击右箭头后图像滑块不滑动

[英]Image slider not sliding after clicking the right arrow

This problem seems quite strange , I checked for replacement for my code but all of them give the same problem . 这个问题似乎很奇怪,我检查了我的代码的替换,但所有这些都给出了同样的问题。 One replacement can be Jquery: mousedown effect (while left click is held down) . 一个替换可以是Jquery:mousedown效果(按住左键单击) I am trying to make a slider that will slide the thumbs of images to right or left . 我正在尝试制作一个滑块,将图像的拇指向右或向左滑动。 From the thumbs the person can then choose and click the image he wants and it will get displayed .The thumbs can slide to both right and left . 然后,人们可以从拇指中选择并单击他想要的图像并显示它。拇指可以向右和向左滑动。 The problem is that after clicking the right button the images don't slide again towards left , I think it is something with clearinterval . 问题是,点击右键后图像不会再向左滑动,我认为这是一个有明确间隔的东西。 Here is the fiddle , http://jsfiddle.net/2rfm5/18/ After clicking the right arrow the left sliding effect wont work . 这是小提琴, http://jsfiddle.net/2rfm5/18/点击右箭头后左侧滑动效果不起作用。

$("#popUpInnerArrowLeft").mousedown(function(event) {
           movetoleft();
});

var into ,into2 ;

function movetoleft() {
    function moveit() { 
     $(".thumbsInnerContainer").animate({right:'+=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);
});

http://jsfiddle.net/arXnZ/ http://jsfiddle.net/arXnZ/

The issue is with the use of $(document).mouseup() 问题是使用$(document).mouseup()

You should be doing something like : 你应该做的事情如下:

$('#popUpInnerArrowRight, #popUpInnerArrowLeft ').mouseup(function(){
    clearInterval(stillDown);
});

Check the fiddle for a full example of how to do this. 查看小提琴,了解如何执行此操作的完整示例。

Here it works for me, http://jsfiddle.net/2rfm5/19/ 这对我有用http://jsfiddle.net/2rfm5/19/

And I only changed, 而我只是改变了,

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

to

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM