index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. var __assign = (this && this.__assign) || Object.assign || function(t) {
  12. for (var s, i = 1, n = arguments.length; i < n; i++) {
  13. s = arguments[i];
  14. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  15. t[p] = s[p];
  16. }
  17. return t;
  18. };
  19. import * as React from 'react';
  20. import { DragactList } from '../lib/dragactList/dragactList';
  21. var Words = [
  22. { content: 'You can do anything, but not everything.', img: 'http://pic.sc.chinaz.com/files/pic/pic9/201303/xpic10472.jpg' },
  23. { 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' },
  24. { 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' },
  25. { content: 'Those who believe in telekinetics, raise my hand.', img: 'https://tctechcrunch2011.files.wordpress.com/2017/10/26099344353_18cd6fabb8_k.jpg?w=738' },
  26. { content: 'I’d rather live with a good question than a bad answer.', img: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQVa26cLzh6PYUwY4LMpwbHyDHFmWi_w2JuqDzeOdm1IIEbBZO0Vg' }
  27. ];
  28. var Cell = function (props) {
  29. var item = props.item;
  30. return (React.createElement("div", { className: 'layout-Cell', style: { width: 400, height: 50, border: '1px solid black' } },
  31. React.createElement("img", { src: item.img, style: { width: 45, height: 45 }, draggable: false, alt: 'card' }),
  32. React.createElement("div", { style: { paddingLeft: 12, color: '#595959' } }, item.content)));
  33. };
  34. var dataList = [
  35. __assign({ y: 0 }, Words[0], { key: '0' }),
  36. __assign({ y: 1 }, Words[1], { key: '1' }),
  37. __assign({ y: 2 }, Words[2], { key: '2' }),
  38. __assign({ y: 3 }, Words[3], { key: '3' })
  39. ];
  40. var dataList2 = [
  41. __assign({ y: 0 }, Words[0], { key: '100' }),
  42. __assign({ y: 1 }, Words[1], { key: '101' }),
  43. __assign({ y: 2 }, Words[2], { key: '201' }),
  44. __assign({ y: 3 }, Words[3], { key: '301' })
  45. ];
  46. var SortableList = /** @class */ (function (_super) {
  47. __extends(SortableList, _super);
  48. function SortableList() {
  49. return _super !== null && _super.apply(this, arguments) || this;
  50. }
  51. SortableList.prototype.render = function () {
  52. var _this = this;
  53. var list = [dataList, dataList2];
  54. return (React.createElement("div", { style: { display: 'flex', justifyContent: 'center' } },
  55. React.createElement("div", null,
  56. React.createElement("h1", { style: { textAlign: 'center' } }, "Sort list Demo"),
  57. React.createElement(DragactList, { layout: list, width: 450, rowHeight: 60, margin: [50, 5], className: 'normal-layout', ref: function (node) { return _this.one = node; } }, function (child, index) {
  58. return React.createElement(Cell, { item: child });
  59. }))));
  60. };
  61. return SortableList;
  62. }(React.Component));
  63. export { SortableList };