Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the option to change trackXVisible and trackYVisible classes #421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/Scrollbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ if (isBrowser) {
);
}


const DEFAULT_TRACK_Y_VISIBLE_CLASS_NAME = "trackYVisible";
const DEFAULT_TRACK_X_VISIBLE_CLASS_NAME = "trackXVisible";

export type ScrollbarProps = ElementPropsWithElementRefAndRenderer & {
createContext?: boolean;

Expand Down Expand Up @@ -95,6 +99,9 @@ export type ScrollbarProps = ElementPropsWithElementRefAndRenderer & {
onScroll?: (scrollValues: ScrollState, prevScrollState: ScrollState) => void;
onScrollStart?: (scrollValues: ScrollState) => void;
onScrollStop?: (scrollValues: ScrollState) => void;

trackXVisibleClassName?: string
trackYVisibleClassName?: string
};

export type ScrollbarState = {
Expand Down Expand Up @@ -836,9 +843,15 @@ export default class Scrollbar extends React.Component<ScrollbarProps, Scrollbar

children,

trackXVisibleClassName,
trackYVisibleClassName,

...propsHolderProps
} = this.props as ScrollbarProps;

const trackXVisibleClassNameToRender = trackXVisibleClassName ?? DEFAULT_TRACK_X_VISIBLE_CLASS_NAME
const trackYVisibleClassNameToRender = trackYVisibleClassName ?? DEFAULT_TRACK_Y_VISIBLE_CLASS_NAME

const scrollbarWidth = !util.isUndef(propsScrollbarWidth)
? propsScrollbarWidth
: util.getScrollbarWidth() || 0;
Expand All @@ -862,8 +875,8 @@ export default class Scrollbar extends React.Component<ScrollbarProps, Scrollbar
...propsHolderProps,
className: cnb(
'ScrollbarsCustom native',
this.state.trackYVisible && 'trackYVisible',
this.state.trackXVisible && 'trackXVisible',
this.state.trackYVisible && trackYVisibleClassNameToRender,
this.state.trackXVisible && trackXVisibleClassNameToRender,
this.state.isRTL && 'rtl',
propsHolderProps.className
),
Expand Down Expand Up @@ -1003,8 +1016,8 @@ export default class Scrollbar extends React.Component<ScrollbarProps, Scrollbar
...propsHolderProps,
className: cnb(
'ScrollbarsCustom',
this.state.trackYVisible && 'trackYVisible',
this.state.trackXVisible && 'trackXVisible',
this.state.trackYVisible && trackYVisibleClassNameToRender,
this.state.trackXVisible && trackXVisibleClassNameToRender,
this.state.isRTL && 'rtl',
propsHolderProps.className
),
Expand Down