Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 3 additions & 6 deletions examples/simple/components/ColoredScrollbars/App.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions examples/simple/components/ColoredScrollbars/ColoredScrollbars.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React, { createClass } from 'react';
import React, { Component } from 'react';
import { Scrollbars } from 'react-custom-scrollbars';

export default createClass({
export default class ColoredScrollbars extends Component {

displayName: 'ColoredScrollbars',

getInitialState() {
return {
top: 0
};
},
constructor(props, ...rest) {
super(props, ...rest);
this.state = { top: 0 };
this.handleUpdate = this.handleUpdate.bind(this);
this.renderView = this.renderView.bind(this);
this.renderThumb = this.renderThumb.bind(this);
}

handleUpdate(values) {
const { top } = values;
this.setState({ top });
},
}

renderView({ style, ...props }) {
const { top } = this.state;
Expand All @@ -29,7 +29,7 @@ export default createClass({
style={{ ...style, ...viewStyle }}
{...props}/>
);
},
}

renderThumb({ style, ...props }) {
const { top } = this.state;
Expand All @@ -41,7 +41,7 @@ export default createClass({
style={{ ...style, ...thumbStyle }}
{...props}/>
);
},
}

render() {
return (
Expand All @@ -53,4 +53,4 @@ export default createClass({
{...this.props}/>
);
}
});
}
9 changes: 3 additions & 6 deletions examples/simple/components/DefaultScrollbars/App.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions examples/simple/components/ShadowScrollbars/App.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 16 additions & 13 deletions examples/simple/components/ShadowScrollbars/ShadowScrollbars.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import css from 'dom-css';
import React, { createClass, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Scrollbars } from 'react-custom-scrollbars';

export default createClass({
class ShadowScrollbars extends Component {

displayName: 'ShadowScrollbars',

propTypes: {
style: PropTypes.object
},

getInitialState() {
return {
constructor(props, ...rest) {
super(props, ...rest);
this.state = {
scrollTop: 0,
scrollHeight: 0,
clientHeight: 0
};
},
this.handleUpdate = this.handleUpdate.bind(this);
}

handleUpdate(values) {
const { shadowTop, shadowBottom } = this.refs;
Expand All @@ -26,7 +23,7 @@ export default createClass({
const shadowBottomOpacity = 1 / 20 * (bottomScrollTop - Math.max(scrollTop, bottomScrollTop - 20));
css(shadowTop, { opacity: shadowTopOpacity });
css(shadowBottom, { opacity: shadowBottomOpacity });
},
}

render() {
const { style, ...props } = this.props;
Expand Down Expand Up @@ -65,4 +62,10 @@ export default createClass({
</div>
);
}
});
}

ShadowScrollbars.propTypes = {
style: PropTypes.object
};

export default ShadowScrollbars;
13 changes: 8 additions & 5 deletions examples/simple/components/SpringScrollbars/App.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions examples/simple/components/SpringScrollbars/SpringScrollbars.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
import React, { createClass } from 'react';
import React, { Component } from 'react';
import { Scrollbars } from 'react-custom-scrollbars';
import { SpringSystem, MathUtil } from 'rebound';

export default createClass({
export default class SpringScrollbars extends Component {

displayName: 'SpringScrollbars',
constructor(props, ...rest) {
super(props, ...rest);
this.handleSpringUpdate = this.handleSpringUpdate.bind(this);
}

componentDidMount() {
this.springSystem = new SpringSystem();
this.spring = this.springSystem.createSpring();
this.spring.addListener({ onSpringUpdate: this.handleSpringUpdate });
},
}

componentWillUnmount() {
this.springSystem.deregisterSpring(this.spring);
this.springSystem.removeAllListeners();
this.springSystem = undefined;
this.spring.destroy();
this.spring = undefined;
},
}

getScrollTop() {
return this.refs.scrollbars.getScrollTop();
},
}

getScrollHeight() {
return this.refs.scrollbars.getScrollHeight();
},
}

getHeight() {
return this.refs.scrollbars.getHeight();
},
}

scrollTop(top) {
const { scrollbars } = this.refs;
Expand All @@ -39,13 +42,13 @@ export default createClass({
const val = MathUtil.mapValueInRange(top, 0, scrollHeight, scrollHeight * 0.2, scrollHeight * 0.8);
this.spring.setCurrentValue(scrollTop).setAtRest();
this.spring.setEndValue(val);
},
}

handleSpringUpdate(spring) {
const { scrollbars } = this.refs;
const val = spring.getCurrentValue();
scrollbars.scrollTop(val);
},
}

render() {
return (
Expand All @@ -54,4 +57,4 @@ export default createClass({
ref="scrollbars"/>
);
}
});
}
1 change: 1 addition & 0 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"dependencies": {
"css-loader": "^0.23.1",
"prop-types": "^15.5.8",
"rebound": "0.0.13"
}
}
20 changes: 8 additions & 12 deletions lib/Scrollbars/defaultRenderElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ function renderViewDefault(props) {
}

function renderTrackHorizontalDefault(_ref) {
var style = _ref.style;

var props = _objectWithoutProperties(_ref, ['style']);
var style = _ref.style,
props = _objectWithoutProperties(_ref, ['style']);

var finalStyle = _extends({}, style, {
right: 2,
Expand All @@ -40,9 +39,8 @@ function renderTrackHorizontalDefault(_ref) {
}

function renderTrackVerticalDefault(_ref2) {
var style = _ref2.style;

var props = _objectWithoutProperties(_ref2, ['style']);
var style = _ref2.style,
props = _objectWithoutProperties(_ref2, ['style']);

var finalStyle = _extends({}, style, {
right: 2,
Expand All @@ -55,9 +53,8 @@ function renderTrackVerticalDefault(_ref2) {
}

function renderThumbHorizontalDefault(_ref3) {
var style = _ref3.style;

var props = _objectWithoutProperties(_ref3, ['style']);
var style = _ref3.style,
props = _objectWithoutProperties(_ref3, ['style']);

var finalStyle = _extends({}, style, {
cursor: 'pointer',
Expand All @@ -68,9 +65,8 @@ function renderThumbHorizontalDefault(_ref3) {
}

function renderThumbVerticalDefault(_ref4) {
var style = _ref4.style;

var props = _objectWithoutProperties(_ref4, ['style']);
var style = _ref4.style,
props = _objectWithoutProperties(_ref4, ['style']);

var finalStyle = _extends({}, style, {
cursor: 'pointer',
Expand Down
Loading