@opentiny/vue-renderless
Version:
An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.
44 lines (43 loc) • 1.21 kB
JavaScript
import "../chunk-G2ADBYYC.js";
import { isDisplayNone } from "@opentiny/utils";
const clickList = ({ emit, props }) => () => {
const list = {
id: props.id,
content: props.content,
subtext: props.subText,
contentdes: props.contentDes
};
emit("click", list);
};
const check = ({ api, emit, props, state, vm }) => () => {
if (state.loading || props.finished || props.disabled || props.error || // skip check when inside an inactive tab
state.tabStatus === false) {
return;
}
const offset = +props.offset;
const scrollParentRect = api.useRect(state.scroller);
if (!scrollParentRect.height || isDisplayNone(vm.$el)) {
return;
}
let isReachEdge = false;
const placeholderRect = api.useRect(vm.$refs.placeholder);
if (props.direction === "up") {
isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
} else {
isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
}
if (isReachEdge) {
state.loading = true;
emit("update:loading", true);
emit("load");
}
};
const clickErrorText = ({ api, emit }) => () => {
emit("update:error", false);
api.check();
};
export {
check,
clickErrorText,
clickList
};