From: Vincent Vanwaelscappel Date: Fri, 4 Mar 2022 18:04:05 +0000 (+0100) Subject: wait #5145 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=bd5aee58902545ee556b4f4fd91f11ac458a36e2;p=fluidbook-html5.git wait #5145 @0.5 --- diff --git a/js/libs/fluidbook/fluidbook.articles.js b/js/libs/fluidbook/fluidbook.articles.js index 89aaa2df..c274a40e 100644 --- a/js/libs/fluidbook/fluidbook.articles.js +++ b/js/libs/fluidbook/fluidbook.articles.js @@ -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) { diff --git a/style/menu-articles.less b/style/menu-articles.less index 6877f6ed..76c358c4 100644 --- a/style/menu-articles.less +++ b/style/menu-articles.less @@ -110,6 +110,12 @@ width: 100%; height: 100%; pointer-events: auto; + opacity: 0; + transition: opacity 250ms; + &.visible { + transition: opacity 250ms; + opacity: 1; + } } iframe.print{