javascript - TouchSwipe all events -
i trying handle events in function. in gamelogic function each type of event.
although, tap doesn't recognized ...
what should ? should separate each event ?
$(function() { $(".main-wrapper-inner").swipe( { //generic swipe handler directions tap:function(event, target) { gamelogic("tap"); }, swipeleft:function(event, distance, duration, fingercount, fingerdata) { gamelogic("swipeleft"); }, swiperight:function(event, distance, duration, fingercount, fingerdata) { gamelogic("swiperight"); }, swipeup:function(event, distance, duration, fingercount, fingerdata) { gamelogic("swipeup"); }, swipedown:function(event, distance, duration, fingercount, fingerdata) { gamelogic("swipedown"); }, pinchin:function(event, direction, distance, duration, fingercount, pinchzoom, fingerdata) { gamelogic("pinchin"); }, pinchout:function(event, direction, distance, duration, fingercount, pinchzoom, fingerdata) { gamelogic("pinchout"); }, threshold:0, fingers: 'all' }); });
you can obtain swipe direction (but not pinch direction), can reduce lot of code (see below).
regarding tap, must not set threshold: 0
internally disable tap/click events. set threshold
higher 0, or omit (defaults 75) make tap functions works
$(function() { $(".main-wrapper-inner").swipe( { //generic swipe handler directions tap:function(event, target) { gamelogic("tap"); }, swipe(event, direction) { // can obtain swipe direction // , process in game logic gamelogic("swipe", direction); } pinchin:function(event) { gamelogic("pinchin"); }, pinchout:function(event) { gamelogic("pinchout"); }, threshold: 75, // must not 0 taps work fingers: 'all' }); });
Comments
Post a Comment