import { __awaiter, __generator } from "tslib"; import { PaginationDefaultProps } from './props'; import '../_util/assert-component2'; Component({ props: PaginationDefaultProps, data: { pageDeg: 0, supportSjs: my.canIUse('sjs.event'), }, wrapWidth: 0, methods: { clacWidth: function () { return __awaiter(this, void 0, void 0, function () { var _this = this; return __generator(this, function (_a) { return [2 /*return*/, new Promise(function (resolve) { my.createSelectorQuery() .select("#ant-pageInfinite-".concat(_this.$id)) .boundingClientRect() .exec(function (ret) { if (ret && ret[0]) { _this.wrapWidth = ret[0].width; } resolve(_this.wrapWidth); }); })]; }); }); }, onScroll: function (e) { return __awaiter(this, void 0, void 0, function () { var _a, scrollLeft, scrollWidth, viewWidth; return __generator(this, function (_b) { switch (_b.label) { case 0: _a = e.detail, scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth; return [4 /*yield*/, this.clacWidth()]; case 1: viewWidth = _b.sent(); if (viewWidth) { this.setData({ pageDeg: Math.ceil((scrollLeft / (scrollWidth - viewWidth)) * 100), }); } return [2 /*return*/]; } }); }); }, }, });