index.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // import *as React from 'react';
  2. // import { Dragact } from '../lib/dragact';
  3. // const Words = [
  4. // { content: 'You can do anything, but not everything.', img: 'http://pic.sc.chinaz.com/files/pic/pic9/201303/xpic10472.jpg' },
  5. // { content: 'Those who dare to fail miserably can achieve greatly.', img: 'https://img00.deviantart.net/1163/i/2013/059/d/7/irish_views_by_ssquared_photography-d5wjnsk.jpg' },
  6. // { content: 'You miss 100 percent of the shots you never take.', img: 'http://www.landsendhotel.co.uk/uploads/gallery/gallery/coastal_scenery_seascapes_6.jpg' },
  7. // { content: 'Those who believe in telekinetics, raise my hand.', img: 'https://tctechcrunch2011.files.wordpress.com/2017/10/26099344353_18cd6fabb8_k.jpg?w=738' },
  8. // { content: 'I’d rather live with a good question than a bad answer.', img: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQVa26cLzh6PYUwY4LMpwbHyDHFmWi_w2JuqDzeOdm1IIEbBZO0Vg' }
  9. // ]
  10. // const Card = (props: any) => {
  11. // const item: any = props.item;
  12. // const dataSet: any = props['data-set'];
  13. // return (
  14. // <div className='layout-Item' >
  15. // <img src={item.img} style={{ width: '100%', height: '60%' }} draggable={false} alt='card'></img>
  16. // <div style={{ padding: 5, textAlign: 'center', color: '#595959' }}>{dataSet.handle ? <div className='card-handle' id="dragact-handle">点我拖动</div> : item.content}</div>
  17. // </div>
  18. // )
  19. // }
  20. // export class AddRemove extends React.Component<{}, {}> {
  21. // layoutWrap: HTMLDivElement | null
  22. // dragactNode: Dragact;
  23. // state = {
  24. // layout: [1]
  25. // }
  26. // componentDidMount() {
  27. // this.setState({
  28. // layout: this.dragactNode.getLayout()
  29. // })
  30. // }
  31. // handleClick = () => {
  32. // this.setState({
  33. // layout: [...this.state.layout, 1]
  34. // })
  35. // console.log(this.state.layout)
  36. // }
  37. // handleDeleteClick = () => {
  38. // this.state.layout.shift()
  39. // this.setState({
  40. // layout: [...this.state.layout]
  41. // })
  42. // }
  43. // render() {
  44. // const margin: [number, number] = [5, 5];
  45. // const dragactInit = {
  46. // width: 800,
  47. // col: 12,
  48. // rowHeight: 800 / 12,
  49. // margin: margin,
  50. // className: 'normal-layout'
  51. // }
  52. // return (
  53. // <div>
  54. // <div style={{ display: 'flex', justifyContent: 'center' }} >
  55. // <div>
  56. // <h1 style={{ textAlign: 'center' }}>AddRemove Demo</h1>
  57. // <Dragact {...dragactInit} ref={node => node ? this.dragactNode = node : null} >
  58. // {this.state.layout.map((el, i) => {
  59. // return (
  60. // <Card item={Words[0]} key={i} data-set={{ GridX: i * 3, GridY: 0, w: 3, h: 3 }} />
  61. // )
  62. // })}
  63. // </Dragact>
  64. // <button onClick={this.handleClick}>新增</button>
  65. // <button onClick={this.handleDeleteClick}>删除</button>
  66. // </div>
  67. // </div>
  68. // </div>
  69. // )
  70. // }
  71. // }