Skip to content

Commit

Permalink
fix: use getComputedStyle to get scrollContainer position
Browse files Browse the repository at this point in the history
  • Loading branch information
linxianxi committed Jun 11, 2024
1 parent dd984a7 commit 0ee4e3e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Selectable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ function Selectable<T>(
// https://github.com/linxianxi/react-selectable-box/issues/5
if (shouldDraggingStart && (boxWidth > 1 || boxHeight > 1)) {
setIsDragging(true);
scrollContainerOriginPosition = scrollContainer.style.position;
if (scrollContainer !== document.body && !scrollContainerOriginPosition) {
scrollContainerOriginPosition = getComputedStyle(scrollContainer).position;
// default position in browser is `static`
if (scrollContainer !== document.body && scrollContainerOriginPosition === 'static') {
scrollContainer.style.position = 'relative';
}
handleStart(e);
Expand Down

0 comments on commit 0ee4e3e

Please sign in to comment.