Browse Source

Fix Panzoom centering if minScale < 1

pull/243/head
Jānis Skarnelis 3 years ago
parent
commit
dbe8e4f2f0
  1. 8
      src/Carousel/Carousel.js
  2. 27
      src/Panzoom/Panzoom.js

8
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;

27
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 };

Loading…
Cancel
Save