Skip to content

Commit

Permalink
Add customizable classnames for bar and container
Browse files Browse the repository at this point in the history
  • Loading branch information
avanes committed Dec 19, 2016
1 parent dc2dc89 commit 0b02b97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ then open [http://localhost:8003](http://localhost:8003).
className={String}
style={Object}
contentClassName={String}
containerClassName={String}
scrollbarClassName={String}
contentStyle={Object}
horizontal={Boolean}
horizontalContainerStyle={Object}
Expand Down Expand Up @@ -132,6 +134,12 @@ Inline styles applied to the main scroll area component.
#### contentClassName
CSS class names added to element with scroll area content.

#### containerClassName
CSS class name added to scrollbar container element.

#### scrollbarClassName
CSS class name added to scrollbar element.

#### contentStyle
Inline styles applied to element with scroll area content.

Expand Down
6 changes: 6 additions & 0 deletions src/js/ScrollArea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export default class ScrollArea extends React.Component {
onPositionChange={this.handleScrollbarYPositionChange.bind(this)}
containerStyle={this.props.verticalContainerStyle}
scrollbarStyle={this.props.verticalScrollbarStyle}
className={this.props.scrollbarClassName}
containerClassName={this.props.containerClassName}
smoothScrolling={withMotion}
minScrollSize={this.props.minScrollSize}
onFocus={this.focusContent.bind(this)}
Expand All @@ -115,6 +117,8 @@ export default class ScrollArea extends React.Component {
onPositionChange={this.handleScrollbarXPositionChange.bind(this)}
containerStyle={this.props.horizontalContainerStyle}
scrollbarStyle={this.props.horizontalScrollbarStyle}
className={this.props.scrollbarClassName}
containerClassName={this.props.containerClassName}
smoothScrolling={withMotion}
minScrollSize={this.props.minScrollSize}
onFocus={this.focusContent.bind(this)}
Expand Down Expand Up @@ -454,6 +458,8 @@ ScrollArea.propTypes = {
style: React.PropTypes.object,
speed: React.PropTypes.number,
contentClassName: React.PropTypes.string,
scrollbarClassName: React.PropTypes.string,
containerClassName: React.PropTypes.string,
contentStyle: React.PropTypes.object,
vertical: React.PropTypes.bool,
verticalContainerStyle: React.PropTypes.object,
Expand Down
8 changes: 5 additions & 3 deletions src/js/Scrollbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ class ScrollBar extends React.Component {
}

render(){
let {smoothScrolling, isDragging, type, scrollbarStyle, containerStyle} = this.props;
let {smoothScrolling, isDragging, type, scrollbarStyle, className, containerStyle, containerClassName} = this.props;
let isVoriziontal = type === 'horizontal';
let isVertical = type === 'vertical';
let scrollStyles = this.createScrollStyles();
let springifiedScrollStyles = smoothScrolling ? modifyObjValues(scrollStyles, x => spring(x)) : scrollStyles;

let scrollbarClasses = `scrollbar-container ${isDragging ? 'active' : ''} ${isVoriziontal ? 'horizontal' : ''} ${isVertical ? 'vertical' : ''}`;
let scrollbarClasses = `scrollbar-container ${containerClassName || ''} ${isDragging ? 'active' : ''} ${isVoriziontal ? 'horizontal' : ''} ${isVertical ? 'vertical' : ''}`;

return (
<Motion style={springifiedScrollStyles}>
Expand All @@ -77,7 +77,7 @@ class ScrollBar extends React.Component {
ref={ x => this.scrollbarContainer = x }
>
<div
className="scrollbar"
className={`scrollbar ${className || ''}`}
style={{ ...scrollbarStyle, ...style }}
onMouseDown={this.handleMouseDown.bind(this)}
/>
Expand Down Expand Up @@ -167,6 +167,8 @@ ScrollBar.propTypes = {
realSize: React.PropTypes.number,
containerSize: React.PropTypes.number,
position: React.PropTypes.number,
className: React.PropTypes.string,
containerClassName: React.PropTypes.string,
containerStyle: React.PropTypes.object,
scrollbarStyle: React.PropTypes.object,
type: React.PropTypes.oneOf(['vertical', 'horizontal']),
Expand Down

0 comments on commit 0b02b97

Please sign in to comment.