index.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { ScrollList, ScrollItem, Button } from '@douyinfe/semi-ui';
  2. import React from 'react';
  3. class SingleScrollListDemo extends React.Component {
  4. constructor(props) {
  5. super(props);
  6. this.state = {
  7. selectIndex3: -2,
  8. };
  9. this.minutes = new Array(60).fill(0).map((itm, index) => {
  10. return {
  11. value: index,
  12. disabled: index % 2 === 1 ? true : false,
  13. };
  14. });
  15. this.onSelectMinute = this.onSelectMinute.bind(this);
  16. this.handleClose = this.handleClose.bind(this);
  17. this.renderFooter = this.renderFooter.bind(this);
  18. }
  19. onSelectMinute(data) {
  20. console.log('You have choose the minute for: ', data.value);
  21. this.setState({
  22. ['selectIndex' + data.type]: data.index,
  23. });
  24. }
  25. handleClose() {
  26. console.log('close');
  27. }
  28. renderFooter() {
  29. return (
  30. <Button size="small" type="primary" onClick={this.handleClose}>
  31. Ok
  32. </Button>
  33. );
  34. }
  35. render() {
  36. let list = this.list;
  37. const scrollStyle = {
  38. border: 'unset',
  39. boxShadow: 'unset',
  40. };
  41. const commonProps = {
  42. // mode: 'normal',
  43. mode: 'wheel',
  44. cycled: false,
  45. motion: false,
  46. };
  47. return (
  48. <div>
  49. <ScrollList style={scrollStyle} header={'单个无限滚动列表'} footer={this.renderFooter()}>
  50. <ScrollItem
  51. {...commonProps}
  52. list={this.minutes}
  53. type={3}
  54. selectedIndex={this.state.selectIndex3}
  55. onSelect={this.onSelectMinute}
  56. aria-label="分钟"
  57. cycled
  58. />
  59. </ScrollList>
  60. </div>
  61. );
  62. }
  63. }
  64. export default SingleScrollListDemo;