mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Throttle PDF.js resize listener (#16402)
GitOrigin-RevId: 5c1498d21197b09865930e1b2deff049022d2d17
This commit is contained in:
parent
fc8892e4fb
commit
a50ca25f3a
1 changed files with 3 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
import PropTypes from 'prop-types'
|
||||
import { memo, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { debounce } from 'lodash'
|
||||
import { debounce, throttle } from 'lodash'
|
||||
import PdfViewerControls from './pdf-viewer-controls'
|
||||
import { useProjectContext } from '../../../shared/context/project-context'
|
||||
import usePersistedState from '../../../shared/hooks/use-persisted-state'
|
||||
|
@ -359,9 +359,9 @@ function PdfJsViewer({ url, pdfFile }) {
|
|||
// adjust the scale when the container is resized
|
||||
useEffect(() => {
|
||||
if (pdfJsWrapper && 'ResizeObserver' in window) {
|
||||
const resizeListener = () => {
|
||||
const resizeListener = throttle(() => {
|
||||
pdfJsWrapper.updateOnResize()
|
||||
}
|
||||
}, 250)
|
||||
|
||||
const resizeObserver = new ResizeObserver(resizeListener)
|
||||
resizeObserver.observe(pdfJsWrapper.container)
|
||||
|
|
Loading…
Reference in a new issue