Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Ensure element styles set via pt merge with required `xBarRef` and `yBarRef` styles

The following styles for "barX" can not be overridden:
 - width
 - left
 - bottom

 The following styles for "barY" can not be overridden:
 - height
 - top
 - right
  • Loading branch information
gcko committed Sep 25, 2024
1 parent f487a2f commit a62e878
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/lib/scrollpanel/ScrollPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,18 @@ export const ScrollPanel = React.forwardRef((inProps, ref) => {
DomHandler.addClass(xBarRef.current, 'p-scrollpanel-hidden');
} else {
DomHandler.removeClass(xBarRef.current, 'p-scrollpanel-hidden');
xBarRef.current.style.cssText = 'width:' + Math.max(scrollXRatio.current * 100, 10) + '%; left:' + (contentRef.current.scrollLeft / totalWidth) * 100 + '%;bottom:' + bottom + 'px;';
xBarRef.current.style.width = Math.max(scrollXRatio.current * 100, 10) + '%';
xBarRef.current.style.left = (contentRef.current.scrollLeft / totalWidth) * 100 + '%';
xBarRef.current.style.bottom = bottom + 'px';
}

if (scrollYRatio.current >= 1) {
DomHandler.addClass(yBarRef.current, 'p-scrollpanel-hidden');
} else {
DomHandler.removeClass(yBarRef.current, 'p-scrollpanel-hidden');
yBarRef.current.style.cssText = 'height:' + Math.max(scrollYRatio.current * 100, 10) + '%; top: calc(' + (contentRef.current.scrollTop / totalHeight) * 100 + '% - ' + xBarRef.current.clientHeight + 'px);right:' + right + 'px;';
yBarRef.current.style.height = Math.max(scrollYRatio.current * 100, 10) + '%';
yBarRef.current.style.top = 'calc(' + (contentRef.current.scrollTop / totalHeight) * 100 + '% - ' + xBarRef.current.clientHeight + 'px)';
yBarRef.current.style.right = right + 'px';
}
});
};
Expand Down

0 comments on commit a62e878

Please sign in to comment.