52 lines
2.1 KiB
JavaScript
52 lines
2.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var tslib_1 = require("tslib");
|
|
var props_1 = require("./props");
|
|
Component({
|
|
props: props_1.PaginationDefaultProps,
|
|
data: {
|
|
pageDeg: 0,
|
|
supportSjs: my.canIUse('sjs.event'),
|
|
},
|
|
wrapWidth: 0,
|
|
methods: {
|
|
clacWidth: function () {
|
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
var _this = this;
|
|
return tslib_1.__generator(this, function (_a) {
|
|
return [2 /*return*/, new Promise(function (resolve) {
|
|
my.createSelectorQuery()
|
|
.select("#pageInfinite".concat(_this.$id))
|
|
.boundingClientRect()
|
|
.exec(function (ret) {
|
|
if (ret && ret[0]) {
|
|
_this.wrapWidth = ret[0].width;
|
|
}
|
|
resolve(_this.wrapWidth);
|
|
});
|
|
})];
|
|
});
|
|
});
|
|
},
|
|
onScroll: function (e) {
|
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
var _a, scrollLeft, scrollWidth, viewWidth;
|
|
return tslib_1.__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*/];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
}); |