zanurano / jquery-ui-for-ipad-and-iphone

Automatically exported from code.google.com/p/jquery-ui-for-ipad-and-iphone
0 stars 0 forks source link

Conflicts with other touch-enabled functionality #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi. Great plugin. I had some special code to do a multi-touch selection on a 
canvas element that this plugin conflicted with, though. 

May I suggest rewriting this plugin to only be enabled for certain elements? 
Like so:

//
// Extend jQuery feature detection (make global)
//

$.extend($.support, {
    touch: typeof Touch == "object"
});

$.fn.addTouch = function()
    {

        this.each(function(i,el){

            //
            // Hook up touch events
            //
            if ($.support.touch) {
                el.addEventListener("touchstart", iPadTouchHandler, false);
                el.addEventListener("touchmove", iPadTouchHandler, false);
                el.addEventListener("touchend", iPadTouchHandler, false);
                el.addEventListener("touchcancel", iPadTouchHandler, false);
            }
        });

        var lastTap = null; 
        ....

});

Also, I think the right-click handler should be optional, since it takes up 
more resources.

Thanks!

Original issue reported on code.google.com by matt.mot...@gmail.com on 8 Sep 2010 at 8:53

GoogleCodeExporter commented 8 years ago
Thanks for you contribution!
That is a great solution for avoiding conflict.

I only posted the code so people wouldn't have to go to the amount of effort I 
had to support jQuery UI however don't really have time to make changes or 
update. I'll post your solution on the wiki.

Original comment by taka...@gmail.com on 10 Sep 2010 at 4:46

GoogleCodeExporter commented 8 years ago
I understand the concept of adding to each element as needed, but I am not yet 
up to speed with jquery.  Can you provide a working example of how to use this 
code on a jquery-ui element -- say a slider control?

Thank you,
Bill

Original comment by WGGreath...@gmail.com on 16 Sep 2010 at 12:59

GoogleCodeExporter commented 8 years ago
I wonder if your code paste above is how it "should" be.. 

I inserted it this way in my jquery.ui.ipad.js copy:

$(function() {
    //
    // Extend jQuery feature detection
    //
    $.fn.addTouch = function() {
    $.extend($.support, {
      touch: typeof Touch == "object"
      });

    //
    // Hook up touch events
    //
    this.each(function(i,el){
      if ($.support.touch) {
      document.addEventListener("touchstart", iPadTouchHandler, false);
      document.addEventListener("touchmove", iPadTouchHandler, false);
      document.addEventListener("touchend", iPadTouchHandler, false);
      document.addEventListener("touchcancel", iPadTouchHandler, false);
      }
      });
    });
});

var lastTap = null;
...

Wonder if it is correct though.

Now, how to make use of it.. you would have a demo example like Bill asked :-)

Kind Regards,

Original comment by mittipro...@gmail.com on 23 Sep 2010 at 11:32

GoogleCodeExporter commented 8 years ago
I can't get this to work, any suggestions?

Original comment by denni...@gmail.com on 29 Sep 2010 at 9:59