Check for the presence of window.ResizeObserver (#5924)

GitOrigin-RevId: d072c9313967b52370a870fc2d30b50c498d8d1d
This commit is contained in:
Alf Eaton 2021-11-29 11:59:34 +00:00 committed by Copybot
parent 33ea150b98
commit 2e3f56c0d4
3 changed files with 7 additions and 6 deletions

View file

@ -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()
}

View file

@ -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)
}

View file

@ -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(
() =>