3

I am developing a web application for touch screen using JQuery, I used iosSlider
I put many divs inside the sliding container, now how can I differentiate between sliding the container and clicking on any div inside it ?? when I slide the container and move my hand out of it , JQuery consider it as a click on an inner div I used JQuery dblclick as a handler for the inner divs temporary but that is not what I want, I want a single click this page shows exactly what I mean Touch Screen Project

Evan Lévesque
  • 3,115
  • 7
  • 40
  • 61
  • never use, never try, but did u try using `mousedown()` or check this links and see if helps you: http://stackoverflow.com/questions/6042202/how-to-distinguish-mouse-click-and-drag and http://jquerymobile.com/demos/1.0a2/#docs/api/events.html – Ricardo Binns Jun 12 '12 at 12:38
  • thanks @RicardoArruda the first link solved the whole thing , thanks alot – Evan Lévesque Jun 13 '12 at 09:02

2 Answers2

0

I solved it this way using JQuery:

        $(".element").each(function(){
            flag = 0;
            $(this).bind("mousedown",function(){
                flag = 0;
            });

            $(this).bind("mousemove",function(){
                flag = 1;
            });

            $(this).bind("mouseup",function(){
                if(flag === 0){
                    console.log("click");                   
                }
                else if(flag === 1){
                    console.log("drag");
                }
            });
        })
Evan Lévesque
  • 3,115
  • 7
  • 40
  • 61
0

I built iosSlider and am still actively working on it. iosSlider is able to handle inline anchor links and inline onclick's when it comes to differentiating between a click and a drag. If there is a bug in the script or a case I'm not thinking of, I would love to troubleshoot it!

For my research, my question is: how are you binding the click event? $().bind('click')/$().click()?

Next time, if you have an issue with iosSlider specifically. I can help you over on github (https://github.com/iosscripts/iosSlider/issues). Just create a new issue and I will take a look at it :).

Thanks.

Marcus
  • 230
  • 4
  • 8