mirror of
https://github.com/flynx/PortableMag.git
synced 2025-10-29 11:10:08 +00:00
now all magazine moves are transform based...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
98df17477e
commit
0daed0a12d
46
magazine.js
46
magazine.js
@ -213,6 +213,26 @@ function getPageAt(n){
|
|||||||
return $(page[n])
|
return $(page[n])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shiftMagazineTo(offset){
|
||||||
|
var mag = $('.magazine')
|
||||||
|
if(USE_TRANSFORM){
|
||||||
|
var transform = 'translate('+ offset +'px, 0px) translateZ(0px)'
|
||||||
|
mag.css({
|
||||||
|
'-ms-transform' : transform,
|
||||||
|
'-webkit-transform' : transform,
|
||||||
|
'-moz-transform' : transform,
|
||||||
|
'-o-transform' : transform,
|
||||||
|
'transform' : transform,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
mag.css({
|
||||||
|
// NOTE: this will be wrong during a transition, that's why we
|
||||||
|
// can pass the pre-calculated offset as an argument...
|
||||||
|
left: offset
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************** event handlers ***/
|
/************************************************** event handlers ***/
|
||||||
@ -300,9 +320,9 @@ function swipeHandler(evt, phase, direction, distance, duration, fingers){
|
|||||||
&& (DRAG_FULL_PAGE || !_PAGE_VIEW)
|
&& (DRAG_FULL_PAGE || !_PAGE_VIEW)
|
||||||
&& (direction=='left' || direction=='right')){
|
&& (direction=='left' || direction=='right')){
|
||||||
if(direction == 'left'){
|
if(direction == 'left'){
|
||||||
mag.css({left: -cur.position()['left']/scale - distance/scale})
|
shiftMagazineTo(-cur.position()['left']/scale - distance/scale)
|
||||||
} else if(direction == 'right') {
|
} else if(direction == 'right') {
|
||||||
mag.css({left: -cur.position()['left']/scale + distance/scale})
|
shiftMagazineTo(-cur.position()['left']/scale + distance/scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.viewer').trigger('magazineDragging')
|
$('.viewer').trigger('magazineDragging')
|
||||||
@ -591,25 +611,9 @@ function setCurrentPage(n, offset, width){
|
|||||||
$('.current.page').removeClass('current')
|
$('.current.page').removeClass('current')
|
||||||
cur.addClass('current')
|
cur.addClass('current')
|
||||||
|
|
||||||
var mag = $('.magazine')
|
// NOTE: this will be wrong during a transition, that's why we
|
||||||
if(USE_TRANSFORM){
|
// can pass the pre-calculated offset as an argument...
|
||||||
var transform = 'translate('+
|
shiftMagazineTo(-(offset == null ? cur.position()['left']/getPageScale() : offset))
|
||||||
-(offset == null ? cur.position()['left']/getPageScale() : offset) +
|
|
||||||
'px, 0px) translateZ(0px)'
|
|
||||||
mag.css({
|
|
||||||
'-ms-transform' : transform,
|
|
||||||
'-webkit-transform' : transform,
|
|
||||||
'-moz-transform' : transform,
|
|
||||||
'-o-transform' : transform,
|
|
||||||
'transform' : transform,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
mag.css({
|
|
||||||
// NOTE: this will be wrong during a transition, that's why we
|
|
||||||
// can pass the pre-calculated offset as an argument...
|
|
||||||
left: -(offset == null ? cur.position()['left']/getPageScale() : offset)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// center the pages correctly...
|
// center the pages correctly...
|
||||||
// NOTE: this is the main reason we need width, and we can get it
|
// NOTE: this is the main reason we need width, and we can get it
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user