aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services/ldzoom.ts
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/services/ldzoom.ts')
-rw-r--r--viewer/src/services/ldzoom.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/viewer/src/services/ldzoom.ts b/viewer/src/services/ldzoom.ts
index f001805..61b5dc6 100644
--- a/viewer/src/services/ldzoom.ts
+++ b/viewer/src/services/ldzoom.ts
@@ -28,7 +28,7 @@ export default class LdZoom {
28 readonly imageElement: HTMLImageElement; 28 readonly imageElement: HTMLImageElement;
29 readonly maxScaleFactor: number; 29 readonly maxScaleFactor: number;
30 readonly zoomSpeed: number; 30 readonly zoomSpeed: number;
31 scaleFactor: number; 31 scaleFactor: number = 0.0;
32 32
33 constructor( 33 constructor(
34 containerElement: HTMLDivElement, imageElement: HTMLImageElement, 34 containerElement: HTMLDivElement, imageElement: HTMLImageElement,
@@ -38,9 +38,12 @@ export default class LdZoom {
38 this.imageElement = imageElement; 38 this.imageElement = imageElement;
39 this.maxScaleFactor = maxScaleFactor; 39 this.maxScaleFactor = maxScaleFactor;
40 this.zoomSpeed = zoomSpeed; 40 this.zoomSpeed = zoomSpeed;
41 this.scaleFactor = imageElement.clientWidth / imageElement.naturalWidth;
42 } 41 }
43 42
43 /**
44 * Register event listeners.
45 * The dimension of the image should be known before calling this method.
46 */
44 public install() { 47 public install() {
45 new ResizeObserver(() => { 48 new ResizeObserver(() => {
46 this.setImageScale(this.scaleFactor); 49 this.setImageScale(this.scaleFactor);
@@ -53,8 +56,6 @@ export default class LdZoom {
53 }); 56 });
54 57
55 // TODO: handle pinch-to-zoom. 58 // TODO: handle pinch-to-zoom.
56
57 this.recenterImageElement();
58 } 59 }
59 60
60 /** 61 /**