dareway-rui
Version:
87 lines (67 loc) • 2.15 kB
JavaScript
;
var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _classCallCheck2 = _interopRequireDefault(require('@babel/runtime/helpers/classCallCheck'));
var _createClass2 = _interopRequireDefault(require('@babel/runtime/helpers/createClass'));
var _LoadingMaskView = _interopRequireDefault(require('./LoadingMaskView'));
var loadingMaskInstance = _LoadingMaskView.default.newInstance();
var count = 0;
function showLoadingMaskView() {
if (count < 0) {
throw new Error('LoadingMask状态异常,计数器【' + count + '】为负值!');
}
if (count == 0) {
loadingMaskInstance.show();
}
count++;
}
function hiddenLoadingMaskView() {
if (count <= 0) {
return;
}
count--;
if (count == 0) {
loadingMaskInstance.hidden();
}
}
var LoadingMask =
/*#__PURE__*/
(function() {
function LoadingMask() {
(0, _classCallCheck2.default)(this, LoadingMask);
this.showTimer = null;
this.isShow = false;
}
(0, _createClass2.default)(LoadingMask, [
{
key: 'show',
value: function show(delayTime) {
var _this = this;
if (!delayTime) {
showLoadingMaskView();
}
this.showTimer = setTimeout(function() {
showLoadingMaskView();
_this.isShow = true;
}, delayTime);
}
},
{
key: 'hidden',
value: function hidden() {
if (this.showTimer) {
clearTimeout(this.showTimer);
}
if (this.isShow) {
hiddenLoadingMaskView();
}
}
}
]);
return LoadingMask;
})();
exports.default = LoadingMask;
//@ sourceMappingURL=index.js.map