editor: fix web clipped screenshot not visible in editor

This commit is contained in:
Abdullah Atta
2025-10-27 12:23:19 +05:00
parent a81c8d0064
commit 1eb0ef0cbe
2 changed files with 5 additions and 8 deletions

View File

@@ -57,7 +57,6 @@ export function ImageComponent(
} | null>(null);
const controllerRef = useRef(new AbortController());
const isMobile = useIsMobile();
const { inView, ref: imageRef } = useObserver<HTMLImageElement>({
threshold: 0.2,
once: true

View File

@@ -45,8 +45,10 @@ export function useObserver<T extends Element = Element>({
);
useEffect(() => {
if (!ref.current) return;
const options = {
root: null,
root: ref.current.closest(".ms-container"),
rootMargin: rootMargin,
threshold: threshold
};
@@ -54,12 +56,8 @@ export function useObserver<T extends Element = Element>({
observer.current = new IntersectionObserver((entries) => {
updateInView(entries[0].isIntersecting);
}, options);
});
useEffect(() => {
if (ref.current) {
observer?.current?.observe(ref.current);
}
observer.current.observe(ref.current);
const reference = ref.current;
@@ -69,7 +67,7 @@ export function useObserver<T extends Element = Element>({
observer.current?.disconnect();
}
};
});
}, [rootMargin, threshold, updateInView]);
return { inView, ref };
}