PHP 8.2.31
Preview: useIframeScale.js Size: 1.11 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/Agent/hooks/useIframeScale.js

import { useLayoutEffect, useRef, useState } from '@wordpress/element';

const VIEWPORT_WIDTH = Math.max(window.innerWidth, 1400);

export const useIframeScale = () => {
	const containerRef = useRef(null);
	const bodyObserverRef = useRef(null);
	const [scale, setScale] = useState(1);
	const [contentHeight, setContentHeight] = useState(null);

	useLayoutEffect(() => {
		const el = containerRef.current;
		if (!el) return;
		const obs = new ResizeObserver(([entry]) => {
			setScale(entry.contentRect.width / VIEWPORT_WIDTH);
		});
		obs.observe(el);
		return () => {
			obs.disconnect();
			bodyObserverRef.current?.disconnect();
		};
	}, []);

	const handleIframeLoad = (e) => {
		const iframeDoc = e.target.contentDocument;
		if (!iframeDoc?.body) return;

		const updateHeight = () => {
			const height = iframeDoc.body.scrollHeight;
			if (height) setContentHeight(height);
		};

		updateHeight();

		bodyObserverRef.current?.disconnect();
		const obs = new ResizeObserver(updateHeight);
		obs.observe(iframeDoc.body);
		bodyObserverRef.current = obs;
	};

	return { containerRef, scale, contentHeight, handleIframeLoad };
};

Directory Contents

Dirs: 0 × Files: 12

Name Size Perms Modified Actions
3.77 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
3.92 KB lrw-r--r-- 2026-03-19 23:35:18
Edit Download
1.11 KB lrw-r--r-- 2026-04-16 23:02:08
Edit Download
607 B lrw-r--r-- 2026-03-24 18:55:54
Edit Download
478 B lrw-r--r-- 2026-03-19 23:35:18
Edit Download
3.17 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
2.39 KB lrw-r--r-- 2026-03-19 23:35:18
Edit Download
1.82 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
1.17 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
1.14 KB lrw-r--r-- 2025-09-09 19:55:14
Edit Download
3.14 KB lrw-r--r-- 2026-03-19 23:35:18
Edit Download
2.20 KB lrw-r--r-- 2026-03-05 22:57:38
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).