From: Stephen Cameron Date: Fri, 30 Jun 2017 13:17:04 +0000 (+0200) Subject: Fix #1514 @3.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=50c5496b71785661696447e49b9a4352ac47a05f;p=fluidbook-html5.git Fix #1514 @3.5 --- diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 86c0ed09..ea4e9877 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -348,6 +348,9 @@ Fluidbook.prototype = { return; }, pageTransition: function (pageNr) { + + $(this).trigger('fluidbook.beforePageTransition'); + this.tooltip.hideTooltip(); if (pageNr == undefined) { pageNr = this.currentPage; diff --git a/js/libs/fluidbook/fluidbook.resize.js b/js/libs/fluidbook/fluidbook.resize.js index 5beb2067..a7400304 100644 --- a/js/libs/fluidbook/fluidbook.resize.js +++ b/js/libs/fluidbook/fluidbook.resize.js @@ -279,6 +279,7 @@ FluidbookResize.prototype = { this.fluidbook.displayOnePage = (this.orientation == 'portrait'); if (changeOrientation) { + $(this.fluidbook).trigger('fluidbook.resize.beforeOrientationChange'); this.fluidbook.zoom.resetZoom(); this.fluidbook.pageTransition(); $(this.fluidbook).trigger('fluidbook.resize.orientation'); diff --git a/js/libs/fluidbook/fluidbook.video.js b/js/libs/fluidbook/fluidbook.video.js index a7dbfc82..931e5530 100644 --- a/js/libs/fluidbook/fluidbook.video.js +++ b/js/libs/fluidbook/fluidbook.video.js @@ -4,7 +4,10 @@ function FluidbookVideo(fluidbook) { this.players = {}; - $(fluidbook).on('changePage', function (e, page) { + // Remove videos before page transition so we can properly handle page turns + // and orientation changes (switching from dual page to single page layout and vice-versa) + $(fluidbook).on('fluidbook.beforePageTransition', function () { + //fb('triggered beforePageTransition -- ' + $this.fluidbook.resize.orientation); $this.removeAllVideos(); }); @@ -12,6 +15,8 @@ function FluidbookVideo(fluidbook) { $this.resizeControls(); }); + + this.fluidbook = fluidbook; this.video = (Modernizr.video && (Modernizr.video.h264 || Modernizr.video.webm || Modernizr.video.ogg)) != false; @@ -65,16 +70,6 @@ FluidbookVideo.prototype = { return; } - // if ($('#videoPopup').length == 0) { - // $('body').append('
'); - // - // $(document).on('click touchend', '.videoPopupLink', function(e) { - // e.preventDefault(); - // $this.openVideo(this); - // return false; - // }); - // } - var id = $(e).data('id'), width = parseFloat($(e).data('width')), height = parseFloat($(e).data('height')), @@ -94,7 +89,12 @@ FluidbookVideo.prototype = { // Player might be active but not visible so we need to dispose of it before re-initialising the element if (videojs.players[id]) { //fb(id + ' player already active. Disposing...'); - videojs(id).dispose(); + try { + videojs(id).dispose(); + } + catch (exception) { + console.warn('Error disposing player #' + id + ' -- ' + exception.message); + } }