Skip to content

Commit e549b44

Browse files
Marc McIntyreMarc McIntyre
Marc McIntyre
authored and
Marc McIntyre
committed
Add getting and setting scrollLeft
1 parent 53e8ff9 commit e549b44

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/StickyTree.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,15 @@ export default class StickyTree<TNodeType extends TreeNode = TreeNode, TMeta = a
558558
return this.elemRef.current ? this.elemRef.current.scrollTop : -1;
559559
}
560560

561+
/**
562+
* Returns the scrollLeft of the scrollable element
563+
*
564+
* @return returns -1 if the elem does not exist.
565+
*/
566+
getScrollLeft() {
567+
return this.elemRef.current ? this.elemRef.current.scrollLeft : -1;
568+
}
569+
561570
/**
562571
* Sets the scrollTop position of the scrollable element.
563572
* @param scrollTop
@@ -568,6 +577,16 @@ export default class StickyTree<TNodeType extends TreeNode = TreeNode, TMeta = a
568577
}
569578
}
570579

580+
/**
581+
* Sets the scrollLeft position of the scrollable element.
582+
* @param scrollLeft
583+
*/
584+
setScrollLeft(scrollLeft: number) {
585+
if (!isNaN(scrollLeft) && this.elemRef.current) {
586+
this.elemRef.current.scrollLeft = scrollLeft;
587+
}
588+
}
589+
571590
/**
572591
* Scrolls the node into view so that it is visible.
573592
*

0 commit comments

Comments
 (0)