mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Check for the presence of window.ResizeObserver (#5924)
GitOrigin-RevId: d072c9313967b52370a870fc2d30b50c498d8d1d
This commit is contained in:
parent
33ea150b98
commit
2e3f56c0d4
3 changed files with 7 additions and 6 deletions
|
@ -220,7 +220,7 @@ function PdfJsViewer({ url }) {
|
|||
|
||||
// adjust the scale when the container is resized
|
||||
useEffect(() => {
|
||||
if (pdfJsWrapper) {
|
||||
if (pdfJsWrapper && 'ResizeObserver' in window) {
|
||||
const resizeListener = () => {
|
||||
pdfJsWrapper.updateOnResize()
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ export const useResizeObserver = handleResize => {
|
|||
|
||||
const elementRef = useCallback(
|
||||
element => {
|
||||
if (element) {
|
||||
if (element && 'ResizeObserver' in window) {
|
||||
if (resizeRef.current) {
|
||||
resizeRef.current.observer.unobserve(resizeRef.current.element)
|
||||
}
|
||||
|
|
|
@ -11,13 +11,14 @@ export default function useToolbarBreakpoint(element) {
|
|||
const [breakpoint, setBreakpoint] = useState(2)
|
||||
const [recalculate, setRecalculate] = useState(true)
|
||||
|
||||
const [resizeObserver] = useState(
|
||||
() =>
|
||||
new ResizeObserver(() => {
|
||||
const [resizeObserver] = useState(() => {
|
||||
if ('ResizeObserver' in window) {
|
||||
return new ResizeObserver(() => {
|
||||
setBreakpoint(2)
|
||||
setRecalculate(true)
|
||||
})
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const [mutationObserver] = useState(
|
||||
() =>
|
||||
|
|
Loading…
Reference in a new issue