mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 11:47:54 +01:00
editor: fix web clipped screenshot not visible in editor
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user