0

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) . 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 .

$("#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);
});
Community
  • 1
  • 1
Siddharth Sharma
  • 1,653
  • 2
  • 19
  • 35

2 Answers2

1

http://jsfiddle.net/arXnZ/

The issue is with the use of $(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.

ericjbasti
  • 2,085
  • 17
  • 19
1

Here it works for me, http://jsfiddle.net/2rfm5/19/

And I only changed,

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

to

    $(".thumbsInnerContainer").animate({
        left: '+=10px'
    });
Optimus Prime
  • 6,817
  • 5
  • 32
  • 60