mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-17 06:00:20 +02:00
fix memory leak on table autoscroll
This commit is contained in:
@@ -104,8 +104,9 @@ export const useTablePaneSync = ({
|
|||||||
target: root,
|
target: root,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let autoScrollCleanup: (() => void) | null = null;
|
||||||
if (enableDrag) {
|
if (enableDrag) {
|
||||||
autoScrollForElements({
|
autoScrollCleanup = autoScrollForElements({
|
||||||
canScroll: () => true,
|
canScroll: () => true,
|
||||||
element: viewport,
|
element: viewport,
|
||||||
getAllowedAxis: () => 'vertical',
|
getAllowedAxis: () => 'vertical',
|
||||||
@@ -114,6 +115,10 @@ export const useTablePaneSync = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
if (autoScrollCleanup) {
|
||||||
|
autoScrollCleanup();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const instance = osInstance();
|
const instance = osInstance();
|
||||||
const { current: root } = scrollContainerRef;
|
const { current: root } = scrollContainerRef;
|
||||||
@@ -147,14 +152,21 @@ export const useTablePaneSync = ({
|
|||||||
|
|
||||||
const viewport = root.firstElementChild as HTMLElement;
|
const viewport = root.firstElementChild as HTMLElement;
|
||||||
|
|
||||||
|
let autoScrollCleanup: (() => void) | null = null;
|
||||||
if (enableDrag) {
|
if (enableDrag) {
|
||||||
autoScrollForElements({
|
autoScrollCleanup = autoScrollForElements({
|
||||||
canScroll: () => true,
|
canScroll: () => true,
|
||||||
element: viewport,
|
element: viewport,
|
||||||
getAllowedAxis: () => 'vertical',
|
getAllowedAxis: () => 'vertical',
|
||||||
getConfiguration: () => ({ maxScrollSpeed: 'fast' }),
|
getConfiguration: () => ({ maxScrollSpeed: 'fast' }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (autoScrollCleanup) {
|
||||||
|
autoScrollCleanup();
|
||||||
|
}
|
||||||
|
};
|
||||||
}, [enableDrag, pinnedLeftColumnCount, pinnedLeftColumnRef]);
|
}, [enableDrag, pinnedLeftColumnCount, pinnedLeftColumnRef]);
|
||||||
|
|
||||||
// Initialize overlayscrollbars for right pinned columns
|
// Initialize overlayscrollbars for right pinned columns
|
||||||
@@ -176,8 +188,9 @@ export const useTablePaneSync = ({
|
|||||||
target: root,
|
target: root,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let autoScrollCleanup: (() => void) | null = null;
|
||||||
if (enableDrag) {
|
if (enableDrag) {
|
||||||
autoScrollForElements({
|
autoScrollCleanup = autoScrollForElements({
|
||||||
canScroll: () => true,
|
canScroll: () => true,
|
||||||
element: viewport,
|
element: viewport,
|
||||||
getAllowedAxis: () => 'vertical',
|
getAllowedAxis: () => 'vertical',
|
||||||
@@ -186,6 +199,10 @@ export const useTablePaneSync = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
if (autoScrollCleanup) {
|
||||||
|
autoScrollCleanup();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const instance = osInstanceRightPinned();
|
const instance = osInstanceRightPinned();
|
||||||
const { current: root } = pinnedRightColumnRef;
|
const { current: root } = pinnedRightColumnRef;
|
||||||
|
|||||||
Reference in New Issue
Block a user