]> _ Git - fluidbook-html5.git/commitdiff
Fix #1514 @3.5
authorStephen Cameron <stephen@cubedesigners.com>
Fri, 30 Jun 2017 13:17:04 +0000 (15:17 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Fri, 30 Jun 2017 13:17:04 +0000 (15:17 +0200)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.resize.js
js/libs/fluidbook/fluidbook.video.js

index 86c0ed096b8776311cd7347208c8d7c3121ff890..ea4e9877ef55d07510e0fbbaa5ecfe9b59128500 100644 (file)
@@ -348,6 +348,9 @@ Fluidbook.prototype = {
         return;
     },
     pageTransition: function (pageNr) {
+
+        $(this).trigger('fluidbook.beforePageTransition');
+
         this.tooltip.hideTooltip();
         if (pageNr == undefined) {
             pageNr = this.currentPage;
index 5beb206782cbb0d15e0b28c86878ffcd25a1219d..a7400304743fe65a0f19549c005986b898bbd861 100644 (file)
@@ -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');
index a7dbfc827b731ed95bd8ddc777b641f928b961ca..931e5530f3d303d4b3eae5eab7c43acf56206e43 100644 (file)
@@ -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('<div id="videoPopupOverlay"></div><div id="videoPopup"><a href="#" class="zoomPopupClose"><svg viewBox="0 0 20 20"><use xlink:href="#close"></use></svg></a></div>');
-        //
-        //     $(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);
+            }
         }