Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(mobile channels): lightbox zoompinch waits for image load (#3351)

Peter Chinman8942f124c722
diff --git a/js/app/packages/core/component/Zoompinch.tsx b/js/app/packages/core/component/Zoompinch.tsx
index e0fa8c88e8..d8f366ab33 100644
--- a/js/app/packages/core/component/Zoompinch.tsx
+++ b/js/app/packages/core/component/Zoompinch.tsx
@@ -82,9 +82,22 @@ export function Zoompinch(props: ZoompinchProps) {
e.wrapperBounds = wrapper.getBoundingClientRect();
}
- e.addEventListener('init', () =>
- e.applyTransform(1, [0.5, 0.5], [0.5, 0.5])
- );
+ // Apply the centering identity transform once bounds are valid.
+ let initialTransformApplied = false;
+ const tryApplyInitialTransform = () => {
+ if (initialTransformApplied) return;
+ if (
+ e.canvasBounds.width > 0 &&
+ e.canvasBounds.height > 0 &&
+ e.wrapperBounds.width > 0 &&
+ e.wrapperBounds.height > 0
+ ) {
+ initialTransformApplied = true;
+ e.applyTransform(1, [0.5, 0.5], [0.5, 0.5]);
+ }
+ };
+ e.addEventListener('init', tryApplyInitialTransform);
+ e.addEventListener('update', tryApplyInitialTransform);
if (onUpdate) e.addEventListener('update', () => onUpdate(e));
// Mouse pan (mousedown on wrapper, move/up on window)