提交 30793656 编写于 作者: Y yangxiaolu3

feat: pullrefresh 更新

上级 142c7b22
view{display:block}.nut-pullrefresh{position:relative;height:100%}.nut-pullrefresh .pullrefresh-top{position:absolute;left:0;overflow:hidden;color:#969799;font-size:14px;line-height:50px;text-align:center}.nut-pullrefresh .pullrefresh-top.pullrefresh-top-v{width:100%;height:50px;-webkit-transform:translateY(-100%);transform:translateY(-100%)}.nut-pullrefresh .pullrefresh-top.pullrefresh-top-h{width:50px;height:100%;-webkit-transform:translateX(-100%);transform:translateX(-100%);writing-mode:tb-rl}.nut-pullrefresh .pullrefresh-content{height:100%;overflow:auto;background:#fff}.nut-pullrefresh .pullrefresh-bottom{position:absolute;overflow:hidden;color:#969799;font-size:14px;line-height:50px;text-align:center}.nut-pullrefresh .pullrefresh-bottom.pullrefresh-bottom-v{left:0;bottom:0;width:100%;height:0px;-webkit-transform:translateY(100%);transform:translateY(100%)}.nut-pullrefresh .pullrefresh-bottom.pullrefresh-bottom-h{top:0;right:0;width:50px;height:100%;-webkit-transform:translateX(100%);transform:translateX(100%);writing-mode:tb-rl}
...@@ -13,18 +13,19 @@ ...@@ -13,18 +13,19 @@
direction == 'horizontal' ? 'pullrefresh-top-h' : 'pullrefresh-top-v' direction == 'horizontal' ? 'pullrefresh-top-h' : 'pullrefresh-top-v'
" "
> >
<template {{ refreshTem }}
<!-- <template
v-if="status == 'loading' && (reachTop || reachLeft) && distance > 0" v-if="status == 'loading' && (reachTop || reachLeft) && distance > 0"
>{{ loadingText }}</template >{{ loadingText.top }}</template
> >
<template <template
v-if="status == 'pulling' && (reachTop || reachLeft) && distance > 0" v-if="status == 'pulling' && (reachTop || reachLeft) && distance > 0"
>{{ pullingText }}</template >{{ pullingText.top }}</template
> >
<template <template
v-if="status == 'loosing' && (reachTop || reachLeft) && distance > 0" v-if="status == 'loosing' && (reachTop || reachLeft) && distance > 0"
>{{ loosingText }}</template >{{ loosingText.top }}</template
> > -->
</view> </view>
<view class="pullrefresh-content" ref="pull"> <view class="pullrefresh-content" ref="pull">
<slot></slot> <slot></slot>
...@@ -43,19 +44,19 @@ ...@@ -43,19 +44,19 @@
v-if=" v-if="
status == 'loading' && (reachBottom || reachRight) && distance < 0 status == 'loading' && (reachBottom || reachRight) && distance < 0
" "
>{{ loadingText }}</template >{{ loadingText.bottom }}</template
> >
<template <template
v-if=" v-if="
status == 'pulling' && (reachBottom || reachRight) && distance < 0 status == 'pulling' && (reachBottom || reachRight) && distance < 0
" "
>{{ pullingText }}</template >{{ pullingText.bottom }}</template
> >
<template <template
v-if=" v-if="
status == 'loosing' && (reachBottom || reachRight) && distance < 0 status == 'loosing' && (reachBottom || reachRight) && distance < 0
" "
>{{ loosingText }}</template >{{ loosingText.bottom }}</template
> >
</view> </view>
</view> </view>
...@@ -89,16 +90,31 @@ export default create({ ...@@ -89,16 +90,31 @@ export default create({
}, },
pullingText: { pullingText: {
type: String, type: Object,
default: '下拉刷新' default: {
top: '下拉刷新',
bottom: '上拉加载',
left: '左滑刷新',
right: '右滑加载'
}
}, },
loosingText: { loosingText: {
type: String, type: Object,
default: '松手释放刷新' default: {
top: '松手释放刷新',
bottom: '松手释放刷新',
left: '松手释放刷新',
right: '松手释放刷新'
}
}, },
loadingText: { loadingText: {
type: String, type: Object,
default: '加载中...' default: {
top: '加载中...',
bottom: '加载中...',
left: '加载中...',
right: '加载中...'
}
} }
}, },
components: {}, components: {},
...@@ -187,6 +203,39 @@ export default create({ ...@@ -187,6 +203,39 @@ export default create({
return style; return style;
}); });
const refreshTem = computed(() => {
const { status, distance } = state;
/** 刷新 顶部或左侧 */
if (
status == 'loading' &&
(reachTop.value || reachLeft.value) &&
distance > 0
) {
return props.loadingText.top;
}
if (
status == 'pulling' &&
(reachTop.value || reachLeft.value) &&
distance > 0
) {
return props.pullingText.top;
}
if (
status == 'loosing' &&
(reachTop.value || reachLeft.value) &&
distance > 0
) {
return props.loosingText.top;
}
/** 刷新 底部或右侧 */
return '';
});
const isTouchable = () => state.status !== 'loading' && !disabled.value; const isTouchable = () => state.status !== 'loading' && !disabled.value;
const setStatus = (distance: number, isLoading?: boolean) => { const setStatus = (distance: number, isLoading?: boolean) => {
...@@ -353,6 +402,7 @@ export default create({ ...@@ -353,6 +402,7 @@ export default create({
reachRight, reachRight,
reachLeft, reachLeft,
getBottomStyle, getBottomStyle,
refreshTem,
...toRefs(state) ...toRefs(state)
}; };
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册