mirror of
https://github.com/flynx/PortableMag.git
synced 2025-11-01 04:20:20 +00:00
minor fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6ff15c5df4
commit
8e6c1be0ec
@ -9,12 +9,19 @@
|
|||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('.viewer')
|
$('.viewer')
|
||||||
.swipe({
|
.swipe({
|
||||||
/* for some reason these do not work within pages... */
|
|
||||||
//swipeLeft: nextPage,
|
//swipeLeft: nextPage,
|
||||||
//swipeRight: prevPage,
|
//swipeRight: prevPage,
|
||||||
swipeStatus: swipeUpdate,
|
swipeStatus: swipeUpdate,
|
||||||
|
// XXX change this to pinch...
|
||||||
swipeUp: function(){fitNPages(6)},
|
swipeUp: function(){fitNPages(6)},
|
||||||
swipeDown: function(){fitNPages(1)},
|
// XXX change this to pinch...
|
||||||
|
swipeDown: function(){
|
||||||
|
fitNPages(1)
|
||||||
|
// to prevent drag while zooming to affect
|
||||||
|
// the resulting position set it to current
|
||||||
|
// page...
|
||||||
|
setCurrentPage()
|
||||||
|
},
|
||||||
click: function(evt, elem){
|
click: function(evt, elem){
|
||||||
if($(elem).hasClass('page')){
|
if($(elem).hasClass('page')){
|
||||||
var pages = $('.page')
|
var pages = $('.page')
|
||||||
@ -34,11 +41,12 @@ function swipeUpdate(evt, phase, direction, distance){
|
|||||||
var cur = $('.current.page')
|
var cur = $('.current.page')
|
||||||
var n = pages.index(cur)
|
var n = pages.index(cur)
|
||||||
var scale = getElementScale($('.scaler'))
|
var scale = getElementScale($('.scaler'))
|
||||||
|
var mag = $('.magazine')
|
||||||
|
|
||||||
if( phase=='move' && (direction=='left' || direction=='right') ){
|
if( phase=='move' && (direction=='left' || direction=='right') ){
|
||||||
// XXX set the transition time to 0...
|
// XXX set the transition time to 0...
|
||||||
var orig_duration = $('.magazine').css('-webkit-transition-duration')
|
var orig_duration = mag.css('-webkit-transition-duration')
|
||||||
$('.magazine').css({'-webkit-transition-duration': 0})
|
mag.css({'-webkit-transition-duration': 0})
|
||||||
if (direction == 'left'){
|
if (direction == 'left'){
|
||||||
//$('.magazine').css({left: -n*cur.width()-distance/scale})
|
//$('.magazine').css({left: -n*cur.width()-distance/scale})
|
||||||
$('.magazine').css({left: -n*800-distance/scale})
|
$('.magazine').css({left: -n*800-distance/scale})
|
||||||
@ -46,18 +54,20 @@ function swipeUpdate(evt, phase, direction, distance){
|
|||||||
//$('.magazine').css({left: -n*cur.width()+distance/scale})
|
//$('.magazine').css({left: -n*cur.width()+distance/scale})
|
||||||
$('.magazine').css({left: -n*800+distance/scale})
|
$('.magazine').css({left: -n*800+distance/scale})
|
||||||
}
|
}
|
||||||
$('.magazine').css({'-webkit-transition-duration': orig_duration})
|
mag.css({'-webkit-transition-duration': orig_duration})
|
||||||
|
|
||||||
} else if ( phase == 'cancel') {
|
} else if ( phase == 'cancel') {
|
||||||
setCurrentPage(pages.index($('.current.page')))
|
setCurrentPage(pages.index($('.current.page')))
|
||||||
|
|
||||||
} else if ( phase =='end' ) {
|
} else if ( phase =='end' ) {
|
||||||
// see which page is closer to the middle of the screen and set it...
|
// see which page is closer to the middle of the screen and set it...
|
||||||
var p = Math.ceil((distance/scale)/cur.width())
|
var p = Math.ceil((distance/scale)/cur.width())
|
||||||
|
|
||||||
if(direction == 'right') {
|
if(direction == 'right') {
|
||||||
//prevPage()
|
// prev page...
|
||||||
setCurrentPage(Math.max(n-p, 0))
|
setCurrentPage(Math.max(n-p, 0))
|
||||||
} else if (direction == 'left'){
|
} else if (direction == 'left'){
|
||||||
//nextPage()
|
// next page...
|
||||||
setCurrentPage(Math.min(n+p, pages.length-1))
|
setCurrentPage(Math.min(n+p, pages.length-1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,13 +75,17 @@ function swipeUpdate(evt, phase, direction, distance){
|
|||||||
|
|
||||||
|
|
||||||
function setCurrentPage(n){
|
function setCurrentPage(n){
|
||||||
|
if(n == null){
|
||||||
|
cur = $('.current.page')
|
||||||
|
} else {
|
||||||
var pages = $('.page')
|
var pages = $('.page')
|
||||||
var cur = $(pages[n])
|
var cur = $(pages[n])
|
||||||
|
}
|
||||||
|
|
||||||
$('.current.page').removeClass('current')
|
$('.current.page').removeClass('current')
|
||||||
cur.addClass('current')
|
cur.addClass('current')
|
||||||
|
|
||||||
$('.magazine').css({left: -n*pages.width()})
|
$('.magazine').css({left: -n*cur.width()})
|
||||||
|
|
||||||
return cur
|
return cur
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user