index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * 封装的通用滚动条,透明颜色
  3. * */
  4. import React, { Component } from 'react';
  5. import { Scrollbars } from 'react-custom-scrollbars';
  6. export default class ColoredScrollbars extends Component {
  7. constructor(props, ...rest) {
  8. super(props, ...rest);
  9. this.state = { top: 0 };
  10. this.handleUpdate = this.handleUpdate.bind(this);
  11. this.renderView = this.renderView.bind(this);
  12. this.renderThumb = this.renderThumb.bind(this);
  13. }
  14. handleUpdate(values) {
  15. const { top } = values;
  16. this.setState({ top });
  17. }
  18. renderView({ style, ...props }) {
  19. const viewStyle = {
  20. backgroundColor: `rgba(0,0,0,0)`
  21. };
  22. return (
  23. <div
  24. className="box"
  25. style={{ ...style, ...viewStyle }}
  26. {...props}/>
  27. );
  28. }
  29. renderThumb({ style, ...props }) {
  30. const thumbStyle = {
  31. backgroundColor: `rgba(0,0,0,0)`
  32. };
  33. return (
  34. <div
  35. style={{ ...style, ...thumbStyle }}
  36. {...props}/>
  37. );
  38. }
  39. render() {
  40. return (
  41. <Scrollbars
  42. renderView={this.renderView}
  43. renderThumbHorizontal={this.renderThumb}
  44. renderThumbVertical={this.renderThumb}
  45. onUpdate={this.handleUpdate}
  46. {...this.props}/>
  47. );
  48. }
  49. }