this._preloadContentLinkTextures(page, this.fluidbook.settings.clinks[page], this.fluidbook.settings.links[page], enter, function (textures, clinks) {
if ($this.fluidbook.pagetransitions.flip3d !== false) {
+
+ let drawTexts = function () {
+ // Draw the texts if necessary
+ if ($this.getVersionToLoad(page) === 'textasvector' || $this.getVersionToLoad(page) === 'vector') {
+ if ($this.fluidbook.support.pdftocanvas) {
+ $this.renderPDFPageToCanvas(page, ctx, dw, dh, function () {
+ afterTexts();
+ });
+ } else {
+ try {
+ let img = $this.texts[page];
+ if (img !== undefined && img !== null) {
+ img = img.get(0);
+ if (img.width === 0) {
+ $this.deletePage(page);
+ $this._preloadPage(page, callback);
+ console.warn('failed to load page for drawing texture ', page);
+ return;
+ }
+ ctx.drawImage(img, -1, 0, dw + 2, dh);
+ }
+ } catch (e) {
+ console.warn(e);
+ }
+ afterTexts();
+ }
+ } else {
+ afterTexts();
+ }
+ };
+
let dh = screen.height * window.devicePixelRatio * 1.1;
let dw = $this.fluidbook.settings.width * (dh / $this.fluidbook.settings.height);
let canvas = $('<canvas class="pscanvas" id="pscanvas_' + page + '" width="' + dw + '" height="' + dh + '" aria-hidden="true"></canvas>');
ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0, 0, dw, dh);
if ($this.backgrounds[page] !== undefined && $this.backgrounds[page] !== null) {
- ctx.drawImage($this.backgrounds[page].get(0), 0, 0, dw * 1.002, dh);
+ let img = $this.backgrounds[page].get(0);
+ if (img.complete) {
+ ctx.drawImage(img, 0, 0, dw * 1.002, dh);
+ drawTexts();
+ } else {
+ let interval = setInterval(function () {
+ if (img.complete) {
+ clearInterval(interval);
+ ctx.drawImage(img, 0, 0, dw * 1.002, dh);
+ drawTexts();
+ }
+ });
+ }
} else {
+ drawTexts();
}
+
+
let afterTexts = function () {
// Draw content links
if (clinks !== '') {
}
};
- // Draw the texts if necessary
- if ($this.getVersionToLoad(page) === 'textasvector' || $this.getVersionToLoad(page) === 'vector') {
- if ($this.fluidbook.support.pdftocanvas) {
- $this.renderPDFPageToCanvas(page, ctx, dw, dh, function () {
- afterTexts();
- });
- } else {
- try {
- let img = $this.texts[page];
- if (img !== undefined && img !== null) {
- img = img.get(0);
- if (img.width === 0) {
- $this.deletePage(page);
- $this._preloadPage(page, callback);
- console.warn('failed to load page for drawing texture ', page);
- return;
- }
- ctx.drawImage(img, -1, 0, dw + 2, dh);
- }
- } catch (e) {
- console.warn(e);
- }
- afterTexts();
- }
- } else {
- afterTexts();
- }
-
} else {
callback();
var callbackCalled = false;
$(img).one('load', function () {
- callback(img);
+ if (img.complete) {
+ callback(img);
+ } else {
+ let interval = setInterval(function () {
+ if (img.complete) {
+ clearInterval(interval);
+ callback(img);
+ }
+ }, 100);
+ }
});
$(img).one('error', function () {