]> _ Git - fluidbook-html5.git/commitdiff
(no commit message)
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 4 Oct 2013 16:32:31 +0000 (16:32 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 4 Oct 2013 16:32:31 +0000 (16:32 +0000)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.loader.js
js/libs/fluidbook/fluidbook.support.js
js/libs/gal/gal.js
style/fluidbook.css

index 849abbe714b20888236656bd9a0e5d4e67be7d87..db0ff92d7f85f0332392976fcc7ba5f3b5271b55 100644 (file)
@@ -95,17 +95,18 @@ Fluidbook.prototype = {
                });\r
        },\r
        hideSplash: function() {\r
-               console.log('hide splash');\r
                if ($("#splash").length == 0) {\r
                        return;\r
                }\r
+               this.loader.canPreload();\r
                var $this = this;\r
                setTimeout(function() {\r
                        $this._hideSplash();\r
                        try {\r
+                               console.log('hide splash');\r
                                navigator.splashscreen.hide();\r
                        } catch (err) {\r
-\r
+                               console.warn('error trying hide splash');\r
                        }\r
                }, 3000);\r
        },\r
index 869a87d92114d5c778982153ef1a9b3ce6523a3c..dbeefa6a3d3303cdbbd527717231ca93cedcc8ee 100644 (file)
@@ -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);
index 1c185ac3c0988a875eb2c280d249aa6ce00ef538..4e366c12a2fc1af8507861a7ae9529033fba9509 100644 (file)
@@ -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;
index 21b48e145bc2371022fb63a3b333d0ce52d0c813..58df043074d164b7d48f83b2390d8f763295526d 100644 (file)
         * 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() {
                                                                bundleName: bundleName,
                                                                success: true
                                                        });
-                                                       callback();
+                                                       setTimeout(function() {
+                                                               callback();
+                                                       }, timeout);
                                                        return;
                                                }
 
                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);
                        }
                });
        };
index 37b1ea0409b24dfd002191582c6288189d6d7380..b694a8bb7957158295a4c74668d4efe8565f8735 100644 (file)
@@ -16,6 +16,7 @@
        display:none;\r
 }\r
 \r
+\r
 /* Global settings */\r
 a,input[type=text],input[type=password],input[type=file],textarea{outline:none;-webkit-appearance:none;}\r
 a{text-decoration:none;color:inherit;}\r
@@ -217,6 +218,11 @@ body{
        position:absolute;\r
        top:0px;\r
        left:0px;\r
+    -webkit-transform: translateZ(0);\r
+    -moz-transform: translateZ(0);\r
+    -ms-transform: translateZ(0);\r
+    -o-transform: translateZ(0);\r
+    transform: translateZ(0);\r
 }\r
 \r
 #shadow>div{\r