SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast britton's Avatar
    Join Date
    Jul 2005
    Location
    Tennessee
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question jQuery Mobile Swipeleft/Swiperight issue.

    I'm implementing a swipe left/swipe right to the mobile photo gallery so phone users can swipe between photos. It works as expected but only once. So if I swipe left or right I go to the next or previous image but then it no longer works.

    Code:
    <script>    
    <? if ($prev != '') { ?>
    
    $(function(){       
    $("#home").bind('swiperight',function(event, ui){
    $.mobile.changePage("/photo.php?id=<?=$prev?>&album=<?=$album?>", "slide");
    });       
    });
    
    <? } if ($next != '') { ?>
    $(function(){        
    $("#home").bind('swipeleft',function(event, ui){
    $.mobile.changePage("/photo.php?id=<?=$next?>&album=<?=$album?>", "slide");
    });       
    });
    <? } ?>
            </script>
    Help?

  2. #2
    SitePoint Enthusiast britton's Avatar
    Join Date
    Jul 2005
    Location
    Tennessee
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm new to jQuery but the problem seems to be..

    Lets say you have 3 photos. We start at picture 2. Swiping left would lead to picture 3... once at picture 3 you would think swiping right would put you back at picture 2 but instead it has that swipe event stored as picture 1. I'm hoping someone knows how to reset these swipes on each page load to the newly presented information.

    Thanks

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Issues with swiping on mobile devices seem to be neatly resolved when using this swipe library
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •