Skip to content

Commit b3d5c37

Browse files
authored
fix: virtual scroll ref (#1217)
* fix: virtual scroll ref * Update Sticky.spec.jsx
1 parent b12a943 commit b3d5c37

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"@rc-component/context": "^1.4.0",
5858
"classnames": "^2.2.5",
5959
"rc-resize-observer": "^1.1.0",
60-
"rc-util": "^5.41.0",
60+
"rc-util": "^5.44.3",
6161
"rc-virtual-list": "^3.14.2"
6262
},
6363
"devDependencies": {

src/stickyScrollBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useContext } from '@rc-component/context';
22
import classNames from 'classnames';
33
import addEventListener from 'rc-util/lib/Dom/addEventListener';
4-
import { getOffset } from 'rc-util/lib/Dom/css';
54
import getScrollBarSize from 'rc-util/lib/getScrollBarSize';
65
import * as React from 'react';
76
import TableContext from './context/TableContext';
87
import { useLayoutState } from './hooks/useFrame';
98
import raf from 'rc-util/lib/raf';
9+
import { getOffset } from './utils/offsetUtil';
1010

1111
interface StickyScrollBarProps {
1212
scrollBodyRef: React.RefObject<HTMLDivElement>;

src/utils/offsetUtil.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { getDOM } from 'rc-util/lib/Dom/findDOMNode';
2+
3+
// Copy from `rc-util/Dom/css.js`
4+
export function getOffset(node: HTMLElement | Window) {
5+
const element = getDOM(node);
6+
const box = element.getBoundingClientRect();
7+
const docElem = document.documentElement;
8+
9+
// < ie8 not support win.pageXOffset, use docElem.scrollLeft instead
10+
return {
11+
left:
12+
box.left +
13+
(window.pageXOffset || docElem.scrollLeft) -
14+
(docElem.clientLeft || document.body.clientLeft || 0),
15+
top:
16+
box.top +
17+
(window.pageYOffset || docElem.scrollTop) -
18+
(docElem.clientTop || document.body.clientTop || 0),
19+
};
20+
}

0 commit comments

Comments
 (0)