From 3e0de1fd7ed8a85e3232f0fdcd918947e0ebef9b Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 4 Oct 2013 16:32:31 +0000 Subject: [PATCH] --- js/libs/fluidbook/fluidbook.js | 5 ++-- js/libs/fluidbook/fluidbook.loader.js | 37 ++++++++++++++++++++------ js/libs/fluidbook/fluidbook.support.js | 7 ++--- js/libs/gal/gal.js | 14 +++++++--- style/fluidbook.css | 6 +++++ 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 849abbe7..db0ff92d 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -95,17 +95,18 @@ Fluidbook.prototype = { }); }, hideSplash: function() { - console.log('hide splash'); if ($("#splash").length == 0) { return; } + this.loader.canPreload(); var $this = this; setTimeout(function() { $this._hideSplash(); try { + console.log('hide splash'); navigator.splashscreen.hide(); } catch (err) { - + console.warn('error trying hide splash'); } }, 3000); }, diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index 869a87d9..dbeefa6a 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -4,14 +4,21 @@ function FluidbookLoader(fluidbook) { this.backgrounds = []; this.links = []; this.toPreload = []; - this.numPreload = 6; + this.numPreload = 0; this.imagesErrors = []; - if (this.fluidbook.imagesVersion) { - this.numPreload += 6; - } + } FluidbookLoader.prototype = { + canPreload: function() { + this.numPreload = 6; + if (this.fluidbook.imagesVersion) { + this.numPreload += 6; + } + if (this.fluidbook.datas.phonegap) { + this.numPreload = 6; + } + }, preloadPagesBeforeTransition: function(pages, callback) { var $this = this; var $pages = pages.slice(0); @@ -60,6 +67,10 @@ FluidbookLoader.prototype = { }); }, preloadAround: function(page) { + if (this.numPreload == 0) { + this.cleanPreloaded(); + return; + } var min = Math.max(1, page - 1); var max = Math.min(min + this.numPreload, this.fluidbook.datas.pages); min = max - (this.numPreload); @@ -202,14 +213,15 @@ FluidbookLoader.prototype = { if (window.gal != undefined) { window.gal.downloadAndCall('content_' + page, function() { $this.__loadBackground(page, callback); - }); + }, 250); } else { this.__loadBackground(page, callback); } } }, __loadBackground: function(page, callback) { - this.backgrounds[page] = this.loadImage(this.getBackgroundURL(page), null, null, null, callback); + var url = this.getBackgroundURL(page); + this.backgrounds[page] = this.loadImage(url, null, null, null, callback); }, loadTexts: function(pageNr, callback) { if (this.fluidbook.imagesVersion) { @@ -249,10 +261,17 @@ FluidbookLoader.prototype = { var img = new Image(); var $this = this; if (callback && typeof callback == 'function') { - $(img).one('load', callback); + $(img).one('load', function() { + setTimeout(function() { + callback(); + }, 100); + }); } $(img).on('error', function() { $this.imagesErrors.push(this); + setTimeout(function() { + callback(); + }, 100); }); img.src = src; if (width != undefined && width != null) { @@ -265,7 +284,9 @@ FluidbookLoader.prototype = { img.type = type; } if (callback && typeof callback == 'function' && (img.complete || img.readyState == 'complete' || img.readyState == 4)) { - callback(); + setTimeout(function() { + callback(); + }, 100); } return $(img); diff --git a/js/libs/fluidbook/fluidbook.support.js b/js/libs/fluidbook/fluidbook.support.js index 1c185ac3..4e366c12 100644 --- a/js/libs/fluidbook/fluidbook.support.js +++ b/js/libs/fluidbook/fluidbook.support.js @@ -9,11 +9,8 @@ function FluidbookSupport(fluidbook) { this.transitions3d = Modernizr.csstransforms3d && Modernizr.csstransformspreserve3d && this.transitions2d; this.transitionendevent = null; - if (Modernizr.mq('(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)')) { - this.resolution = this.fluidbook.datas.retinaResolution; - } else { - this.resolution = 150; - } + + this.resolution = Modernizr.mq('(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)') ? this.fluidbook.datas.retinaResolution : 150; this.isMobile = isMobile(); this.SVG = Modernizr.svg && this.fluidbook.datas.mobileIconVector; diff --git a/js/libs/gal/gal.js b/js/libs/gal/gal.js index 21b48e14..58df0430 100644 --- a/js/libs/gal/gal.js +++ b/js/libs/gal/gal.js @@ -57,7 +57,11 @@ * Downloads assets contained in the named bundle. * @param {string} bundleName name of single bundle to download. */ - GAL.prototype.download = function(bundleName, callback) { + GAL.prototype.download = function(bundleName, callback, timeout) { + if (timeout == undefined) { + timeout = 0; + } + var bundle = this.bundles[bundleName]; if (callback == undefined) { callback = function() { @@ -99,7 +103,9 @@ bundleName: bundleName, success: true }); - callback(); + setTimeout(function() { + callback(); + }, timeout); return; } @@ -155,13 +161,13 @@ addCallback_(this.error, opt_bundleName, callback); }; - GAL.prototype.downloadAndCall = function(bundleName, callback) { + GAL.prototype.downloadAndCall = function(bundleName, callback, timeoutIfNotLoaded) { var $this = this; this.check(bundleName, function(info) { if (info.success) { callback(); } else { - $this.download(bundleName, callback); + $this.download(bundleName, callback, timeoutIfNotLoaded); } }); }; diff --git a/style/fluidbook.css b/style/fluidbook.css index 37b1ea04..b694a8bb 100644 --- a/style/fluidbook.css +++ b/style/fluidbook.css @@ -16,6 +16,7 @@ display:none; } + /* Global settings */ a,input[type=text],input[type=password],input[type=file],textarea{outline:none;-webkit-appearance:none;} a{text-decoration:none;color:inherit;} @@ -217,6 +218,11 @@ body{ position:absolute; top:0px; left:0px; + -webkit-transform: translateZ(0); + -moz-transform: translateZ(0); + -ms-transform: translateZ(0); + -o-transform: translateZ(0); + transform: translateZ(0); } #shadow>div{ -- 2.39.5