Skip to content

Commit

Permalink
fix: classnames undefined if not all defined (fix #228)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grsmto committed Nov 18, 2018
1 parent f0bb5e3 commit 37a4b55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 20 additions & 1 deletion packages/simplebar/demo/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ function menuRenderer(params) {

class Demo extends React.Component {
componentDidMount() {
// new SimpleBar(document.getElementById('manual-instantiation'));
new SimpleBar(document.getElementById('manual-instantiation'));
new SimpleBar(document.getElementById('with-classnames'), {
classNames: { vertical: 'my-custom-class' }
});
}

render() {
Expand Down Expand Up @@ -179,6 +182,22 @@ class Demo extends React.Component {
</div>
</div>
</section>
<section>
<div className="col">
<h2>With custom classnames</h2>
<div
id="with-classnames"
className="demo4"
style={{ width: '200px' }}
>
<div className="box">1</div>
<div className="box">2</div>
<div className="box">3</div>
<div className="box">4</div>
<div className="box">5</div>
</div>
</div>
</section>
</section>
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/simplebar/src/simplebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default class SimpleBar {
this.resizeObserver;
this.scrollbarWidth;
this.minScrollbarWidth = 20;
this.options = Object.assign({}, SimpleBar.defaultOptions, options);
this.options = { ...SimpleBar.defaultOptions, ...options };
this.classNames = { ...SimpleBar.defaultOptions.classNames, ...this.options.classNames };
this.isRtl;
this.classNames = this.options.classNames;
this.axis = {
x: {
scrollOffsetAttr: 'scrollLeft',
Expand Down

0 comments on commit 37a4b55

Please sign in to comment.