index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { __awaiter, __generator } from "tslib";
  2. import { Component } from '../_util/simply';
  3. import { PaginationDefaultProps } from './props';
  4. import { getInstanceBoundingClientRect } from '../_util/jsapi/get-instance-bounding-client-rect';
  5. Component(PaginationDefaultProps, {
  6. clacWidth: function () {
  7. return __awaiter(this, void 0, void 0, function () {
  8. var rect;
  9. return __generator(this, function (_a) {
  10. switch (_a.label) {
  11. case 0: return [4 /*yield*/, getInstanceBoundingClientRect(this, "#ant-pageInfinite-".concat(this.$id ? "-".concat(this.$id) : ''))];
  12. case 1:
  13. rect = _a.sent();
  14. if (rect) {
  15. return [2 /*return*/, rect.width];
  16. }
  17. return [2 /*return*/, 0];
  18. }
  19. });
  20. });
  21. },
  22. onScroll: function (e) {
  23. return __awaiter(this, void 0, void 0, function () {
  24. var _a, scrollLeft, scrollWidth, viewWidth;
  25. return __generator(this, function (_b) {
  26. switch (_b.label) {
  27. case 0:
  28. _a = e.detail, scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth;
  29. return [4 /*yield*/, this.clacWidth()];
  30. case 1:
  31. viewWidth = _b.sent();
  32. if (viewWidth) {
  33. this.setData({
  34. pageDeg: Math.ceil((scrollLeft / (scrollWidth - viewWidth)) * 100),
  35. });
  36. }
  37. return [2 /*return*/];
  38. }
  39. });
  40. });
  41. },
  42. }, {
  43. pageDeg: 0,
  44. supportSjs: true,
  45. }, undefined, {
  46. wrapWidth: 0,
  47. onInit: function () {
  48. var supportSjs;
  49. if (typeof my === 'undefined') {
  50. supportSjs = true;
  51. }
  52. supportSjs = my.canIUse('sjs.event');
  53. this.setData({ supportSjs: supportSjs });
  54. },
  55. });