]> _ Git - fluidbook-html5.git/commitdiff
wait #5145 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 4 Mar 2022 18:04:05 +0000 (19:04 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 4 Mar 2022 18:04:05 +0000 (19:04 +0100)
js/libs/fluidbook/fluidbook.articles.js
style/menu-articles.less

index 89aaa2dfdf6f94ced60f70af32b03cfea4f4efdb..c274a40e660f64c253313be580d8746c018e7fb4 100644 (file)
@@ -1,5 +1,6 @@
 function FluidbookArticles(fluidbook) {
     this.fluidbook = fluidbook;
+    this.initPDFJSIframeInterval = null;
     this.init();
 }
 
@@ -97,26 +98,12 @@ FluidbookArticles.prototype = {
             var view = iframe.parent().parent();
 
             $(this).on('load', function () {
-                var body = $(this).contents().find('body');
-                var m = 25;
-                $(body).on('mousewheel', function (e) {
-                    var d = (e.deltaY * m);
-                    var v = '-=' + d;
-                    if (e.deltaY < 0) {
-                        v = '+=' + (d * -1);
-                    }
-                    $(view).scrollTo(v);
-                });
-                $this.initPDFArticles();
-                setTimeout(function () {
-                    $this.initPDFArticles();
-                }, 1000);
-                setTimeout(function () {
-                    $this.initPDFArticles();
-                }, 2000);
-                setTimeout(function () {
-                    $this.initPDFArticles();
-                }, 3000);
+                var $iframe = this;
+                if (!$this.initIframe($iframe,view)) {
+                    $this.initPDFJSIframeInterval = setInterval(function () {
+                        $this.initIframe($iframe,view);
+                    }, 100);
+                }
             });
         });
 
@@ -135,6 +122,26 @@ FluidbookArticles.prototype = {
 
     },
 
+    initIframe: function (iframe,view) {
+        var body = $(iframe).contents().find('body');
+        if ($(body).length === 0) {
+            return false;
+        }
+        var m = 25;
+        $(body).on('mousewheel', function (e) {
+            var d = (e.deltaY * m);
+            var v = '-=' + d;
+            if (e.deltaY < 0) {
+                v = '+=' + (d * -1);
+            }
+            $(view).scrollTo(v);
+        });
+        this.initPDFArticles();
+        clearInterval(this.initPDFJSIframeInterval);
+        $(iframe).addClass('visible');
+        return true;
+    },
+
     findArticleByURL: function (url) {
         var res = null;
         $.each(this.fluidbook.settings.articlesList, function (k, v) {
index 6877f6eda96b77ccf95a78155ec433774b8a00bd..76c358c4c19a9288ee0c1cc40988b6296ce35770 100644 (file)
     width: 100%;
     height: 100%;
     pointer-events: auto;
+    opacity: 0;
+    transition: opacity 250ms;
+    &.visible {
+      transition: opacity 250ms;
+      opacity: 1;
+    }
   }
 
   iframe.print{