通用评论

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _carousel = require("antd/es/carousel");
  6. var _carousel2 = _interopRequireDefault(_carousel);
  7. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8. require("antd/es/carousel/style");
  9. var _react = require("react");
  10. var _react2 = _interopRequireDefault(_react);
  11. require("./Emoji.css");
  12. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  15. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  16. // import emoji, { prefixUrl } from "../../emoji";
  17. // 每页 20 5*4
  18. // 共 20 * 3 = 60 (实际是 54)
  19. // class Emoji
  20. var Emoji = function (_React$Component) {
  21. _inherits(Emoji, _React$Component);
  22. function Emoji() {
  23. _classCallCheck(this, Emoji);
  24. return _possibleConstructorReturn(this, (Emoji.__proto__ || Object.getPrototypeOf(Emoji)).apply(this, arguments));
  25. }
  26. _createClass(Emoji, [{
  27. key: "next",
  28. value: function next() {
  29. if (this.carousel) {
  30. this.carousel.next();
  31. }
  32. }
  33. }, {
  34. key: "prev",
  35. value: function prev() {
  36. if (this.carousel) {
  37. this.carousel.prev();
  38. }
  39. }
  40. }, {
  41. key: "render",
  42. value: function render() {
  43. var _this2 = this;
  44. var _props = this.props,
  45. _onClick = _props.onClick,
  46. emojiList = _props.emojiList;
  47. var content = [];
  48. // let curPage = [];
  49. // for (let i = 0; i < 115; i++) {
  50. // if (curPage.length < 30) {
  51. // curPage.push(emoji[i]);
  52. // } else {
  53. // content.push(curPage);
  54. // curPage = [];
  55. // }
  56. // }
  57. // if (curPage.length > 0) {
  58. // content.push(curPage);
  59. // }
  60. for (var i = 0; i < emojiList.length; i += 30) {
  61. content.push(emojiList.slice(i, i + 30));
  62. }
  63. return _react2.default.createElement(
  64. _carousel2.default,
  65. {
  66. ref: function ref(node) {
  67. _this2.carousel = node;
  68. }
  69. },
  70. content.map(function (page, index) {
  71. return _react2.default.createElement(
  72. "div",
  73. { key: index, className: "emoji" },
  74. page.map(function (item, index) {
  75. return _react2.default.createElement(
  76. "div",
  77. { className: "item", key: item.id },
  78. _react2.default.createElement("img", {
  79. src: item.url,
  80. alt: item.name,
  81. style: { display: "inline-block", width: "28px" },
  82. onClick: function onClick() {
  83. return _onClick(item.name);
  84. }
  85. })
  86. );
  87. })
  88. );
  89. })
  90. );
  91. }
  92. }]);
  93. return Emoji;
  94. }(_react2.default.Component);
  95. exports.default = Emoji;
  96. //# sourceMappingURL=Emoji.js.map