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...
.swipe({
swipeStatus: swipeHandler,
swipeStatus: makeSwipeHandler(),
// XXX these get called instead of pinches...
swipeUp: function(event, direction, distance, duration, fingerCount){

View File

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