jiaqingjiayi-xiaochengxu/甲情_甲意/miniprogram/node_modules/antd-mini/less/Pagination/index.js

56 lines
2.0 KiB
JavaScript
Raw Normal View History

2024-12-01 11:56:54 +00:00
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];
}
});
});
2024-11-10 07:01:22 +00:00
},
2024-12-01 11:56:54 +00:00
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),
2024-11-10 07:01:22 +00:00
});
2024-12-01 11:56:54 +00:00
}
return [2 /*return*/];
}
2024-11-10 07:01:22 +00:00
});
2024-12-01 11:56:54 +00:00
});
},
}, {
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 });
2024-11-10 07:01:22 +00:00
},
2024-12-01 11:56:54 +00:00
});