tdesign-mobile-vue
Version:
tdesign-mobile-vue
39 lines (34 loc) • 812 B
JavaScript
/**
* tdesign v1.7.0
* (c) 2024 TDesign Group
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
function observe(element, root, callback, marginBottom) {
if (typeof window === "undefined") return null;
if (!window || !window.IntersectionObserver) {
callback();
return null;
}
var io = null;
try {
io = new window.IntersectionObserver(function (entries) {
var entry = entries[0];
if (entry.isIntersecting) {
callback();
io.unobserve(element);
}
}, {
rootMargin: "0px 0px ".concat(marginBottom, "px 0px"),
root: root
});
io.observe(element);
} catch (e) {
console.error(e);
callback();
}
return io;
}
exports["default"] = observe;
//# sourceMappingURL=observe.js.map