jiaqingjiayi-xiaochengxu/甲情_甲意/node_modules/antd-mini/less/Pagination/index.js
2024-11-15 11:51:28 +08:00

56 lines
2.0 KiB
JavaScript

import { __awaiter, __generator } from "tslib";
import { Component } from '../_util/simply';
import { PaginationDefaultProps } from './props';
import { getInstanceBoundingClientRect } from '../_util/jsapi/get-instance-bounding-client-rect';
Component(PaginationDefaultProps, {
clacWidth: function () {
return __awaiter(this, void 0, void 0, function () {
var rect;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getInstanceBoundingClientRect(this, "#ant-pageInfinite-".concat(this.$id ? "-".concat(this.$id) : ''))];
case 1:
rect = _a.sent();
if (rect) {
return [2 /*return*/, rect.width];
}
return [2 /*return*/, 0];
}
});
});
},
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*/];
}
});
});
},
}, {
pageDeg: 0,
supportSjs: true,
}, undefined, {
wrapWidth: 0,
onInit: function () {
var supportSjs;
if (typeof my === 'undefined') {
supportSjs = true;
}
supportSjs = my.canIUse('sjs.event');
this.setData({ supportSjs: supportSjs });
},
});