diff options
author | Arun Persaud <arun@nubati.net> | 2014-03-17 22:32:58 -0700 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2014-03-17 22:32:58 -0700 |
commit | d9d0f02c9c42e154bda18f6843026df6930f9902 (patch) | |
tree | ec6ffa5447dc0330cf879beb5c5dbe38935e325a /js | |
parent | e60e83b04ba2c1b47a4139b1353173ce8a1ca33d (diff) | |
download | e-DoKo-d9d0f02c9c42e154bda18f6843026df6930f9902.tar.gz e-DoKo-d9d0f02c9c42e154bda18f6843026df6930f9902.tar.bz2 e-DoKo-d9d0f02c9c42e154bda18f6843026df6930f9902.zip |
FEATURE: allow swiping to look through tricks on mobile devices
Diffstat (limited to 'js')
-rw-r--r-- | js/game.js | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -60,6 +60,18 @@ function hl_prev() hl(current-1); } +/* check for swipes */ +var down_x = null; +var up_x = null; + +/* advance trick according to swipe direction */ +function do_swipe() +{ + if ((down_x - up_x) > 50) { hl_prev(); } + if ((up_x - down_x) > 50) { hl_next(); } +} + + $(document).ready( function() { @@ -89,5 +101,24 @@ $(document).ready( }); $(".message div div").parent().click ( function() { $(this).hide(); }); - }); + +/* look for swipes left/right */ +$().ready(function(){ + $("div.table").mousedown(function(e){ + down_x = e.pageX; + }); + $("div.table").mouseup(function(e){ + up_x = e.pageX; + do_swipe(); + }); + $("div.table").bind('touchstart', function(e){ + down_x = e.originalEvent.touches[0].pageX; + }); + $("div.table").bind('touchmove', function(e){ + up_x = e.originalEvent.touches[0].pageX; + }); + $("div.table").bind('touchend', function(e){ + do_swipe(); + }); +}); |