mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +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);
|
} | null>(null);
|
||||||
const controllerRef = useRef(new AbortController());
|
const controllerRef = useRef(new AbortController());
|
||||||
|
|
||||||
const isMobile = useIsMobile();
|
|
||||||
const { inView, ref: imageRef } = useObserver<HTMLImageElement>({
|
const { inView, ref: imageRef } = useObserver<HTMLImageElement>({
|
||||||
threshold: 0.2,
|
threshold: 0.2,
|
||||||
once: true
|
once: true
|
||||||
|
|||||||
@@ -45,8 +45,10 @@ export function useObserver<T extends Element = Element>({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!ref.current) return;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
root: null,
|
root: ref.current.closest(".ms-container"),
|
||||||
rootMargin: rootMargin,
|
rootMargin: rootMargin,
|
||||||
threshold: threshold
|
threshold: threshold
|
||||||
};
|
};
|
||||||
@@ -54,12 +56,8 @@ export function useObserver<T extends Element = Element>({
|
|||||||
observer.current = new IntersectionObserver((entries) => {
|
observer.current = new IntersectionObserver((entries) => {
|
||||||
updateInView(entries[0].isIntersecting);
|
updateInView(entries[0].isIntersecting);
|
||||||
}, options);
|
}, options);
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
observer.current.observe(ref.current);
|
||||||
if (ref.current) {
|
|
||||||
observer?.current?.observe(ref.current);
|
|
||||||
}
|
|
||||||
|
|
||||||
const reference = ref.current;
|
const reference = ref.current;
|
||||||
|
|
||||||
@@ -69,7 +67,7 @@ export function useObserver<T extends Element = Element>({
|
|||||||
observer.current?.disconnect();
|
observer.current?.disconnect();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
}, [rootMargin, threshold, updateInView]);
|
||||||
|
|
||||||
return { inView, ref };
|
return { inView, ref };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user