Skip to content

Commit

Permalink
[Mode2UpLit] Fix scale center error
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrini committed Apr 26, 2023
1 parent 1b5f370 commit d880d08
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
3 changes: 0 additions & 3 deletions src/BookReader/Mode1UpLit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ export class Mode1UpLit extends LitElement {
@property({ type: Object })
scaleCenter = { x: 0.5, y: 0.5 };

// Needed for ModeSmoothZoom
worldOffset = { x: 0, y: 0 };

/************** VIRTUAL-SCROLLING PROPERTIES **************/

/** in world coordinates (inches) */
Expand Down
6 changes: 2 additions & 4 deletions src/BookReader/Mode2UpLit.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export class Mode2UpLit extends LitElement {
@property({ type: String })
autoFit = 'auto';

worldOffset = { x: 0, y: 0 };

/************** VIRTUAL-FLIPPING PROPERTIES **************/

/** ms for flip animation */
Expand Down Expand Up @@ -418,8 +416,8 @@ export class Mode2UpLit extends LitElement {
}

recenter(page = this.visiblePages[0]) {
this.worldOffset = this.computeTranslate(page, this.scale);
this.$book.style.transform = `translateX(${this.worldOffset.x}px) translateY(${this.worldOffset.y}px) scale(${this.scale})`;
const translate = this.computeTranslate(page, this.scale);
this.$book.style.transform = `translateX(${translate.x}px) translateY(${translate.y}px) scale(${this.scale})`;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/BookReader/ModeSmoothZoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Hammer from "hammerjs";
* @property {import("./options.js").AutoFitValues} autoFit
* @property {number} scale
* @property {{ x: number, y: number }} scaleCenter
* @property {{ x: number, y: number }} worldOffset
* @property {HTMLDimensionsCacher} htmlDimensionsCacher
* @property {function(): void} [attachScrollListeners]
* @property {function(): void} [detachScrollListeners]
Expand Down Expand Up @@ -206,7 +205,7 @@ export class ModeSmoothZoom {
y: F * oldCenter.y,
};

container.scrollTop = newCenter.y - YPOS * H - this.mode.worldOffset.y;
container.scrollLeft = newCenter.x - XPOS * W - this.mode.worldOffset.x;
container.scrollTop = newCenter.y - YPOS * H;
container.scrollLeft = newCenter.x - XPOS * W;
}
}
1 change: 0 additions & 1 deletion tests/jest/BookReader/ModeSmoothZoom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function dummy_mode(overrides = {}) {
boundingClientRect: { left: 0, top: 0 },
},
scaleCenter: {x: 0.5, y: 0.5},
worldOffset: {x: 0, y: 0},
...overrides
};
}
Expand Down

0 comments on commit d880d08

Please sign in to comment.