]> _ Git - fluidbook-html5.git/commitdiff
fix #2289 @0:50
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Oct 2018 15:03:50 +0000 (17:03 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Oct 2018 15:03:50 +0000 (17:03 +0200)
js/libs/fluidbook/fluidbook.links.js

index 518033c660f173d58835a98876f3f4c975dae2e8..d07a19566dd8cd649c406a7e160bb43a301dddf5 100644 (file)
@@ -239,7 +239,8 @@ FluidbookLinks.prototype = {
             zoomZonesGap = 30, // Space between grouped zoom links
             gapsTotal,
             availableWidth = $(window).width() - (2 * zoomMargin),
-            availableHeight = $(window).height() - (2 * zoomMargin);
+            availableHeight = $(window).height() - (2 * zoomMargin),
+            maxZoom = parseFloat($(link).data('maxzoom')) || 2;
 
         // If the interface is zoomed in, we must zoom out first
         if (this.fluidbook.zoom.zoom > 1) {
@@ -279,23 +280,23 @@ FluidbookLinks.prototype = {
         // Calculate positions and scaling for all zoomLink blocks
         // First, calculate stacked height of all zoomLink blocks
         var stackedHeight = gapsTotal + links.reduce(function (sum, zoomLink) {
-            return sum + (zoomLink.data('height') * zoomLink.data('maxzoom'));
+            return sum + (zoomLink.data('height') * maxZoom);
         }, 0);
 
         // Calculate side-by-side width of all zoomLink blocks
         var sideBySideWidth = gapsTotal + links.reduce(function (sum, zoomLink) {
-            return sum + (zoomLink.data('width') * zoomLink.data('maxzoom'));
+            return sum + (zoomLink.data('width') * maxZoom);
         }, 0);
 
         // Find widest element in collection
         var widestLink = links.reduce(function (maxWidth, zoomLink) {
-            var width = (zoomLink.data('width') * zoomLink.data('maxzoom'));
+            var width = (zoomLink.data('width') * maxZoom);
             return (width > maxWidth) ? width : maxWidth;
         }, 0);
 
         // Find tallest element in collection
         var tallestLink = links.reduce(function (maxHeight, zoomLink) {
-            var height = (zoomLink.data('height') * zoomLink.data('maxzoom'));
+            var height = (zoomLink.data('height') * maxZoom);
             return (height > maxHeight) ? height : maxHeight;
         }, 0);
 
@@ -335,7 +336,7 @@ FluidbookLinks.prototype = {
                 parent = zoomLink.closest('.link'),
                 baseWidth = parseInt(zoomLink.data('width')), // Width of the original link from the editor
                 baseHeight = parseInt(zoomLink.data('height')), // Height of the original link from the editor
-                maxZoom = parseInt(zoomLink.data('maxzoom')) || 2, // The default value for this should match that of the compiler in zoomLink::generateImage()
+                maxZoom = parseFloat(zoomLink.data('maxzoom')) || 2, // The default value for this should match that of the compiler in zoomLink::generateImage()
                 zoomX,
                 zoomY,
                 zoomWidth,
@@ -372,6 +373,9 @@ FluidbookLinks.prototype = {
             zoomWidth = baseWidth * zoomScale;
             zoomHeight = baseHeight * zoomScale;
 
+            // Max zoom of first clicked link
+            var firstMaxZoom = parseFloat(links[0].data('maxzoom')) || 2;
+
             //=========
             // Position elements based on the layout
             // There are two possible layouts: stacked or side-by-side
@@ -392,7 +396,7 @@ FluidbookLinks.prototype = {
 
                     // Otherwise, calculate Y position based on first element position
                 } else {
-                    zoomY = Math.round(groupY + links[0].data('height') * links[0].data('maxzoom') * groupScale + zoomZonesGap + zoomMargin - parent.offset().top);
+                    zoomY = Math.round(groupY + links[0].data('height') * firstMaxZoom * groupScale + zoomZonesGap + zoomMargin - parent.offset().top);
                 }
             } else {
                 // Side-by-side layout
@@ -410,7 +414,7 @@ FluidbookLinks.prototype = {
 
                     // Otherwise, calculate X position based on first element position
                 } else {
-                    zoomX = Math.round(groupX + (links[0].data('width') * links[0].data('maxzoom') * groupScale) + zoomZonesGap + zoomMargin - parent.offset().left);
+                    zoomX = Math.round(groupX + (links[0].data('width') * firstMaxZoom * groupScale) + zoomZonesGap + zoomMargin - parent.offset().left);
                 }
             }
 
@@ -534,8 +538,11 @@ FluidbookLinks.prototype = {
         $(".inlineslideshow").each(function () {
             if ($(this).is(':visible')) {
                 $__this.initSlideshow(this);
-            }else{
-
+            } else {
+                var $s = $(this);
+                $(this).closest('.link').on('fluidbook.link.show', function () {
+                    $__this.initSlideshow($s);
+                });
             }
         });
     },