开发者

jQuery + mobile devices: how do I scroll up and down? (iOS: iPad)

开发者 https://www.devze.com 2023-03-30 04:20 出处:网络
This is the library I\'m using: http://www.netcu.de/jquery-touchwipe-iphone-ipad-library This is the code I have:

This is the library I'm using: http://www.netcu.de/jquery-touchwipe-iphone-ipad-library

This is the code I have:

                $j("#section-content").touchwipe({
                     wipeLeft: function() {$j('#next-page').trigger('click'); },
                     wipeRight: function() { $j('#prev-page').trigger('click');  },
                     wipe开发者_如何学编程Up: function() { alert("up"); },
                     wipeDown: function() { alert("down"); },
                     min_move_x: 20,
                     min_move_y: 20,
                     preventDefaultEvents: true
                });

now, wipeUp and wipeDown appear to not work (I don't see any alerts on the virtual iPad on my mac). The real problem is that when I have an object that can be wiped left and right, it prevents up down wiping (essential for scrolling long pages).

So how do I do I re-enable scrolling via wipe up / wipe down? Are there better jquery libraries that can do this?


In that script you're using, comment out this line:

     function onTouchMove(e) {
         if(config.preventDefaultEvents) {
             // e.preventDefault();
         }

(the prevent default line)

it prevents the mobile browser from doin' it's thang.


You could also try using the following in your code

$("#section-content").touchwipe({
      preventDefaultEvents: false,
      wipeLeft: function() {
      $("#section-content").cycle("next");
      $("#section-content").cycle("pause");
      return false;
    },
    wipeRight: function() {
    $("#section-content").cycle("prev");
    $("#section-content").cycle("pause");
    return false;
    }
    }); 

This is probably the better option because it's usually best not to edit the source code of a plugin as when you update it with a newer version, you have to remember to alter the code....times that by several dozen sites and it could be a real effort!


just set preventDefaultEvents: false

locally like

   $("#section-content").touchwipe({
   preventDefaultEvents: false ...

or globally like

   var config = {
   preventDefaultEvents: true ...
0

精彩评论

暂无评论...
验证码 换一张
取 消