UNPKG

tdesign-vue

Version:
48 lines (42 loc) 1.59 kB
/** * tdesign v1.15.0 * (c) 2026 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var VueCompositionAPI = require('@vue/composition-api'); var _common_js_utils_observe = require('../_common/js/utils/observe.js'); function useLazyLoad(containerRef, childRef, params) { var tRowHeight = VueCompositionAPI.computed(function () { return Math.max(params.rowHeight || 48, 48); }); var isInit = VueCompositionAPI.ref(false); var hasLazyLoadHolder = VueCompositionAPI.computed(function () { return (params === null || params === void 0 ? void 0 : params.type) === "lazy" && !isInit.value; }); var requestAnimationFrame = (typeof window === "undefined" ? false : window.requestAnimationFrame) || function (cb) { return setTimeout(cb, 16.6); }; var init = function init() { if (!isInit.value) { requestAnimationFrame(function () { isInit.value = true; }); } }; VueCompositionAPI.onMounted(function () { if ((params === null || params === void 0 ? void 0 : params.type) !== "lazy") return; VueCompositionAPI.nextTick(function () { var bufferSize = Math.max(10, params.bufferSize || 10); var height = tRowHeight.value * bufferSize; _common_js_utils_observe["default"](childRef.value, containerRef === null || containerRef === void 0 ? void 0 : containerRef.value, init, height); }); }); return { hasLazyLoadHolder: hasLazyLoadHolder, tRowHeight: tRowHeight }; } exports["default"] = useLazyLoad; //# sourceMappingURL=useLazyLoad.js.map