mirror of
https://github.com/flynx/PortableMag.git
synced 2025-12-27 05:42:13 +00:00
some minor refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a04d21e132
commit
eff3279b1c
32
layout.js
32
layout.js
@ -4,11 +4,6 @@
|
|||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
//var NAVIGATE_RELATIVE_TO_VISIBLE = false
|
|
||||||
//var NAVIGATE_RELATIVE_TO_VISIBLE = true
|
|
||||||
|
|
||||||
var USE_PAGE_ALIGN = true
|
|
||||||
|
|
||||||
var PAGES_IN_RIBBON = 4
|
var PAGES_IN_RIBBON = 4
|
||||||
|
|
||||||
|
|
||||||
@ -83,6 +78,8 @@ var togglePageView = createCSSClassToggler(
|
|||||||
// - general configuration
|
// - general configuration
|
||||||
// - optional events...
|
// - optional events...
|
||||||
// XXX should we use a callback or an event???
|
// XXX should we use a callback or an event???
|
||||||
|
// XXX make this get the scrolled item automatically...
|
||||||
|
// ...now $('.magazine') is hardcoded...
|
||||||
function makeScrollHandler(root, callback){
|
function makeScrollHandler(root, callback){
|
||||||
|
|
||||||
// local data...
|
// local data...
|
||||||
@ -149,7 +146,8 @@ function makeScrollHandler(root, callback){
|
|||||||
touches = touch ? event.touches.length : 0
|
touches = touch ? event.touches.length : 0
|
||||||
|
|
||||||
// XXX needs testing...
|
// XXX needs testing...
|
||||||
if(config.autoCancelEvents){
|
// check scroll bounds...
|
||||||
|
if(bounds != null){
|
||||||
if(config.hScroll && (x <= bounds.left || x >= bounds.right)
|
if(config.hScroll && (x <= bounds.left || x >= bounds.right)
|
||||||
|| config.vScroll && (y <= bounds.top || y >= bounds.bottom)){
|
|| config.vScroll && (y <= bounds.top || y >= bounds.bottom)){
|
||||||
// XXX cancel the touch event and trigger the end handler...
|
// XXX cancel the touch event and trigger the end handler...
|
||||||
@ -161,15 +159,16 @@ function makeScrollHandler(root, callback){
|
|||||||
if(scrolling){
|
if(scrolling){
|
||||||
shift += x - prev_x
|
shift += x - prev_x
|
||||||
setElementTransform($('.magazine'), shift, scale)
|
setElementTransform($('.magazine'), shift, scale)
|
||||||
}
|
|
||||||
// XXX these should be done every time the event is caught or
|
|
||||||
// just while scrolling?
|
|
||||||
dx = x - prev_x
|
|
||||||
dt = t - prev_t
|
|
||||||
prev_t = t
|
|
||||||
prev_x = x
|
|
||||||
//root.trigger('userScroll')
|
|
||||||
|
|
||||||
|
// XXX these should be done every time the event is caught or
|
||||||
|
// just while scrolling?
|
||||||
|
dx = x - prev_x
|
||||||
|
dt = t - prev_t
|
||||||
|
prev_t = t
|
||||||
|
prev_x = x
|
||||||
|
|
||||||
|
//root.trigger('userScroll')
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
function endMoveHandler(evt){
|
function endMoveHandler(evt){
|
||||||
@ -180,6 +179,7 @@ function makeScrollHandler(root, callback){
|
|||||||
scrolling = false
|
scrolling = false
|
||||||
scroller.state = 'waiting'
|
scroller.state = 'waiting'
|
||||||
touches = 0
|
touches = 0
|
||||||
|
bounds = null
|
||||||
//togglePageDragging('off')
|
//togglePageDragging('off')
|
||||||
// XXX add speed to this...
|
// XXX add speed to this...
|
||||||
//root.trigger('userScrollEnd')
|
//root.trigger('userScrollEnd')
|
||||||
@ -226,6 +226,7 @@ function makeScrollHandler(root, callback){
|
|||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
// XXX check...
|
||||||
setCallback: function(func){
|
setCallback: function(func){
|
||||||
this.callback = func
|
this.callback = func
|
||||||
},
|
},
|
||||||
@ -288,7 +289,6 @@ function getPageNumber(page){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the next page relative to the current...
|
// get the next page relative to the current...
|
||||||
//if(!NAVIGATE_RELATIVE_TO_VISIBLE){
|
|
||||||
if(!isNavigationViewRelative()){
|
if(!isNavigationViewRelative()){
|
||||||
return $('.page').index($('.current.page'))
|
return $('.page').index($('.current.page'))
|
||||||
|
|
||||||
@ -339,6 +339,7 @@ function setCurrentPage(n){
|
|||||||
}
|
}
|
||||||
var scale = getMagazineScale()
|
var scale = getMagazineScale()
|
||||||
var l = $('.page').length
|
var l = $('.page').length
|
||||||
|
// normalize the number...
|
||||||
n = n < 0 ? l - n : n
|
n = n < 0 ? l - n : n
|
||||||
n = n < -l ? 0 : n
|
n = n < -l ? 0 : n
|
||||||
n = n >= l ? l - 1 : n
|
n = n >= l ? l - 1 : n
|
||||||
@ -350,7 +351,6 @@ function setCurrentPage(n){
|
|||||||
|
|
||||||
// center-align pages in ribbon view...
|
// center-align pages in ribbon view...
|
||||||
var align = isNavigationViewRelative() ? 'center' : null
|
var align = isNavigationViewRelative() ? 'center' : null
|
||||||
|
|
||||||
var left = getMagazineOffset(cur, null, align)
|
var left = getMagazineOffset(cur, null, align)
|
||||||
|
|
||||||
setElementTransform($('.magazine'), left, scale)
|
setElementTransform($('.magazine'), left, scale)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user