tdesign-vue-next
Version:
TDesign Component for vue-next
58 lines (52 loc) • 1.91 kB
JavaScript
/**
* tdesign v1.19.2
* (c) 2026 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var Vue = require('vue');
var observe = require('../../_chunks/dep-b9a88912.js');
var dom = require('../../_chunks/dep-8d990e66.js');
require('../../_chunks/dep-35e23c2b.js');
require('../../_chunks/dep-4a7162e7.js');
require('../../_chunks/dep-2dcf9237.js');
require('../../_chunks/dep-22dc294c.js');
require('@babel/runtime/helpers/typeof');
require('../../_chunks/dep-bf76dead.js');
require('../../_chunks/dep-631750cd.js');
require('../../_chunks/dep-4cb26289.js');
function useLazyLoad(containerRef, childRef, params) {
var tRowHeight = Vue.computed(function () {
return Math.max(params.rowHeight || 48, 48);
});
var isInit = Vue.ref(false);
var hasLazyLoadHolder = Vue.computed(function () {
return (params === null || params === void 0 ? void 0 : params.type) === "lazy" && !isInit.value;
});
var requestAnimationFrame = !dom.isServer && window.requestAnimationFrame || function (cb) {
return setTimeout(cb, 16.6);
};
var init = function init() {
if (!isInit.value) {
requestAnimationFrame(function () {
isInit.value = true;
});
}
};
Vue.onMounted(function () {
if ((params === null || params === void 0 ? void 0 : params.type) !== "lazy") return;
Vue.nextTick(function () {
var bufferSize = Math.max(10, params.bufferSize || 10);
var height = tRowHeight.value * bufferSize;
if (!(childRef !== null && childRef !== void 0 && childRef.value) || !(containerRef !== null && containerRef !== void 0 && containerRef.value)) return;
observe.observe(childRef.value, containerRef.value, init, height);
});
});
return {
hasLazyLoadHolder: hasLazyLoadHolder,
tRowHeight: tRowHeight
};
}
exports["default"] = useLazyLoad;
//# sourceMappingURL=useLazyLoad.js.map