From 40b485d62463dc24127c3dad96a546287be412c9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 16 Nov 2025 13:59:55 +0000 Subject: [PATCH] fix: Reset zoom state properly in destroy() method - Added zoom state reset (scale=1, moveX=0, moveY=0) before cleanup - Explicitly sets transform to 'none' and transition to 'none' - Prevents image from appearing enlarged/overflowed after destroy - Ensures clean state restoration before removing event listeners This fixes the issue where calling destroy() would enlarge the image and cause overflow instead of properly resetting the component state. --- .../src/lib/services/ivy-pinch.service.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/projects/ngx-pinch-zoom/src/lib/services/ivy-pinch.service.ts b/projects/ngx-pinch-zoom/src/lib/services/ivy-pinch.service.ts index b5cc741..5001bac 100644 --- a/projects/ngx-pinch-zoom/src/lib/services/ivy-pinch.service.ts +++ b/projects/ngx-pinch-zoom/src/lib/services/ivy-pinch.service.ts @@ -1551,6 +1551,8 @@ export class IvyPinchService { * Destroys the IvyPinch instance. * * **Cleanup:** + * - Resets zoom to original state + * - Removes CSS transforms * - Removes CSS styles * - Destroys touch event handlers * - Removes event listeners @@ -1560,6 +1562,14 @@ export class IvyPinchService { * @public */ public destroy(): void { + // Reset zoom to initial state before cleanup + this.scale = 1; + this.moveX = 0; + this.moveY = 0; + this.element.style.transform = 'none'; + this.element.style.transition = 'none'; + + // Clean up styles and event listeners this.removeBasicStyles(); this.touches.destroy(); }