diff --git a/src/Carousel/Carousel.js b/src/Carousel/Carousel.js index b96b5b9..454bba7 100644 --- a/src/Carousel/Carousel.js +++ b/src/Carousel/Carousel.js @@ -611,6 +611,10 @@ export class Carousel extends Base { // Lazy load images // === + slide.$el.querySelectorAll("[data-lazy-srcset]").forEach((node) => { + node.srcset = node.dataset.lazySrcset; + }); + slide.$el.querySelectorAll("[data-lazy-src]").forEach((node) => { let lazySrc = node.dataset.lazySrc; @@ -621,10 +625,6 @@ export class Carousel extends Base { } }); - slide.$el.querySelectorAll("[data-lazy-srcset]").forEach((node) => { - node.srcset = node.dataset.lazySrcset; - }); - // Lazy load slide background image // === let lazySrc; diff --git a/src/Panzoom/Panzoom.js b/src/Panzoom/Panzoom.js index 3d65ce7..3dc2bfc 100644 --- a/src/Panzoom/Panzoom.js +++ b/src/Panzoom/Panzoom.js @@ -920,33 +920,28 @@ export class Panzoom extends Base { scale = scale || this.transform.scale; - const fitWidth = this.content.fitWidth; - const fitHeight = this.content.fitHeight; - - const width = fitWidth * scale; - const height = fitHeight * scale; + const width = this.content.fitWidth * scale; + const height = this.content.fitHeight * scale; const viewportWidth = this.viewport.width; const viewportHeight = this.viewport.height; - if (fitWidth <= viewportWidth) { - const deltaX1 = (viewportWidth - width) * 0.5; - const deltaX2 = (width - fitWidth) * 0.5; + if (width < viewportWidth) { + const deltaX = round((viewportWidth - width) * 0.5); - boundX.from = round(deltaX1 - deltaX2); - boundX.to = round(deltaX1 + deltaX2); + boundX.from = deltaX; + boundX.to = deltaX; } else { boundX.from = round(viewportWidth - width); } - if (fitHeight <= viewportHeight) { - const deltaY1 = (viewportHeight - height) * 0.5; - const deltaY2 = (height - fitHeight) * 0.5; + if (height < viewportHeight) { + const deltaY = (viewportHeight - height) * 0.5; - boundY.from = round(deltaY1 - deltaY2); - boundY.to = round(deltaY1 + deltaY2); + boundY.from = deltaY; + boundY.to = deltaY; } else { - boundY.from = round(viewportHeight - width); + boundY.from = round(viewportHeight - height); } return { boundX, boundY };