From 98df17477ea5225aa09ea3e96e615fcb79d5f6b8 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 14 Feb 2013 07:33:04 +0400 Subject: [PATCH] added transform-based setCurrentPage to index.html... Signed-off-by: Alex A. Naanou --- magazine.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/magazine.js b/magazine.js index baefc22..5009ee8 100755 --- a/magazine.js +++ b/magazine.js @@ -52,6 +52,8 @@ var UPDATE_HASH_URL_POSITION = false // NOTE: partial history navigation over links will still work. var FULL_HISTORY_ENABLED = false +var USE_TRANSFORM = true + /*********************************************************** modes ***/ @@ -590,11 +592,24 @@ function setCurrentPage(n, offset, width){ cur.addClass('current') var mag = $('.magazine') - 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) - }) + if(USE_TRANSFORM){ + var transform = 'translate('+ + -(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... // NOTE: this is the main reason we need width, and we can get it