【问题标题】:Image slider not sliding after clicking the right arrow单击右箭头后图像滑块不滑动
【发布时间】:2013-08-09 02:18:55
【问题描述】:

这个问题看起来很奇怪,我检查了我的代码是否可以替换,但它们都给出了同样的问题。一个替换可以是 Jquery: mousedown effect (while left click is held down) 。 我正在尝试制作一个滑块,将图像的拇指向右或向左滑动。然后人们可以从拇指中选择并单击他想要的图像,它将显示出来。拇指可以左右滑动。 问题是单击右键后图像不会再次向左滑动,我认为这是 clearinterval 的东西。 这是小提琴,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);
});

【问题讨论】:

  • 你能不能设置一个fiddle来试试这个。
  • jsfiddle.net/2rfm5/18@OptimusPrime
  • 对我来说它向左和向右滑动,有变化,你还有什么问题?
  • 按右箭头后不会向左滑动。
  • 检查我的答案,希望对您有所帮助

标签: javascript jquery slider


【解决方案1】:

这对我有用,http://jsfiddle.net/2rfm5/19/

而我只是变了,

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

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

【讨论】:

  • 我从没想过,这会有所作为。谢谢。
【解决方案2】:

http://jsfiddle.net/arXnZ/

问题在于使用 $(document).mouseup()

你应该做类似的事情:

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

查看小提琴以获取有关如何执行此操作的完整示例。

【讨论】:

    猜你喜欢
    • 2015-11-22
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    • 2018-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多