Migrate from react-virtualized to react-window
This commit is contained in:
parent
675e350da3
commit
4482dd33ce
8 changed files with 241 additions and 152 deletions
|
@ -2,6 +2,7 @@ import { getCharWidth } from 'state/app';
|
|||
import { updateMessageHeight } from 'state/messages';
|
||||
import { when } from 'utils/observe';
|
||||
import { measureScrollBarWidth } from 'utils';
|
||||
import { addResizeListener } from 'utils/size';
|
||||
|
||||
const menuWidth = 200;
|
||||
const messagePadding = 30;
|
||||
|
@ -13,8 +14,7 @@ export default function widthUpdates({ store }) {
|
|||
const scrollBarWidth = measureScrollBarWidth();
|
||||
let prevWrapWidth;
|
||||
|
||||
function updateWidth() {
|
||||
const windowWidth = window.innerWidth;
|
||||
function updateWidth(windowWidth) {
|
||||
let wrapWidth = windowWidth - scrollBarWidth - messagePadding;
|
||||
if (windowWidth > smallScreen) {
|
||||
wrapWidth -= menuWidth;
|
||||
|
@ -26,16 +26,6 @@ export default function widthUpdates({ store }) {
|
|||
}
|
||||
}
|
||||
|
||||
let resizeRAF;
|
||||
|
||||
function resize() {
|
||||
if (resizeRAF) {
|
||||
window.cancelAnimationFrame(resizeRAF);
|
||||
}
|
||||
resizeRAF = window.requestAnimationFrame(updateWidth);
|
||||
}
|
||||
|
||||
updateWidth();
|
||||
window.addEventListener('resize', resize);
|
||||
addResizeListener(updateWidth, true);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue