re-did the swipe-handler...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-19 00:55:49 +04:00
parent 88d0494f17
commit c28a3bb116
2 changed files with 63 additions and 51 deletions

View File

@ -59,7 +59,7 @@ $(document).ready(function(){
// user interactions... // user interactions...
.swipe({ .swipe({
swipeStatus: swipeHandler, swipeStatus: makeSwipeHandler(),
// XXX these get called instead of pinches... // XXX these get called instead of pinches...
swipeUp: function(event, direction, distance, duration, fingerCount){ swipeUp: function(event, direction, distance, duration, fingerCount){

View File

@ -361,31 +361,42 @@ function viewResizeHandler(){
// each call while dragging... // each call while dragging...
// XXX for some reason with finger count of 3 and greater, touchSwipe // XXX for some reason with finger count of 3 and greater, touchSwipe
// dies on android... // dies on android...
function swipeHandler(evt, phase, direction, distance, duration, fingers){ function makeSwipeHandler(){
var pages = $('.page') var pages
var cur = $('.current.page') var cur
var n = pages.index(cur) var n
var scale = getPageScale() var scale
var mag = $('.magazine') var mag
var pos = $('.navigator .bar .indicator') var pos
var viewer
return function(evt, phase, direction, distance, duration, fingers){
if(phase == 'start'){
// NOTE: this is used with the "unanimated" trick, we will make
// dragging real-time...
togglePageDragging('on')
// setup the data for the drag...
pages = $('.page')
cur = $('.current.page')
n = pages.index(cur)
scale = getPageScale()
mag = $('.magazine')
pos = $('.navigator .bar .indicator')
viewer = $('.viewer')
// XXX make this drag pages that are larger than view before dragging outside... // XXX make this drag pages that are larger than view before dragging outside...
if(phase=='move' } else if(phase=='move'
// see if wee need to drag the page and allways drag the ribbon... // see if wee need to drag the page and allways drag the ribbon...
&& (DRAG_FULL_PAGE || !_PAGE_VIEW) && (DRAG_FULL_PAGE || !_PAGE_VIEW)
&& (direction=='left' || direction=='right')){ && (direction=='left' || direction=='right')){
if(direction == 'left'){ if(direction == 'left'){
shiftMagazineTo(-cur.position()['left']/scale - distance/scale) shiftMagazineTo(-cur.position().left/scale - distance/scale)
} else if(direction == 'right') { } else if(direction == 'right') {
shiftMagazineTo(-cur.position()['left']/scale + distance/scale) shiftMagazineTo(-cur.position().left/scale + distance/scale)
} }
viewer.trigger('magazineDragging')
$('.viewer').trigger('magazineDragging')
} else if(phase == 'start'){
// NOTE: this is used with the "unanimated" trick, we will make
// dragging real-time...
togglePageDragging('on')
} else if(phase == 'cancel'){ } else if(phase == 'cancel'){
togglePageDragging('off') togglePageDragging('off')
@ -419,6 +430,7 @@ function swipeHandler(evt, phase, direction, distance, duration, fingers){
} }
} }
} }
}
} }