Skip to content

Commit

Permalink
Merge pull request #55 from Tencent/revert-53-feat/update_pulldownref…
Browse files Browse the repository at this point in the history
…resh

Revert "Feat/update pulldownrefresh"
  • Loading branch information
josonyang authored Apr 2, 2022
2 parents bec2b36 + 3deb73c commit 7f54648
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 323 deletions.
8 changes: 2 additions & 6 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ export interface TVNode extends VNode {
name: string;
}
export type TNodeReturnValue = SlotReturnValue;

// 严格执行是否有参数,不允许出现 props?:T
export type TNode<T = undefined> = T extends undefined
? (h: typeof import('vue').h) => TNodeReturnValue
: (h: typeof import('vue').h, props: T) => TNodeReturnValue;
export type TNode<T = any> = (h: typeof import('vue').h, props?: T) => import('vue').VNodeChild;

export type AttachNodeReturnValue = HTMLElement | Element | Document;
export type AttachNode = CSSSelector | ((triggerNode?: HTMLElement) => AttachNodeReturnValue);
export type AttachNode = CSSSelector | (() => AttachNodeReturnValue);

// 与滚动相关的容器类型,因为 document 上没有 scroll 相关属性, 因此排除document
export type ScrollContainerElement = Window | HTMLElement;
Expand Down
33 changes: 9 additions & 24 deletions src/pull-down-refresh/demos/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@
<t-tabs default-value="first" @on-change="onChange">
<t-tab-panel value="first" label="基础用法">
<div class="refresh-content">
<t-pull-down-refresh
:value="refreshing1"
class="demo-pull-down-refresh"
@refresh="handleRefresh(1)"
@change="handleChangeRefreshing1"
<t-pull-down-refresh v-model="refreshing1" class="demo-pull-down-refresh" @refresh="handleRefresh(1)"
><div class="content-text">已下拉{{ refreshCount1 }}次</div></t-pull-down-refresh
>
</div>
</t-tab-panel>
<t-tab-panel value="second" label="自定义文案">
<div class="refresh-content">
<t-pull-down-refresh
:value="refreshing2"
:on-change="handleChangeRefreshing2"
v-model="refreshing2"
class="demo-pull-down-refresh"
:loading-texts="['下拉即可刷新...', '释放即可刷新...', '加载中...', '刷新成功']"
@refresh="handleRefresh(2)"
Expand All @@ -35,7 +30,7 @@
v-model="refreshing3"
class="demo-pull-down-refresh"
:loading-texts="['下拉即可刷新...', '释放即可刷新...', '加载中...', '刷新成功']"
:refresh-timeout="2000"
:refresh-timeout="1000"
@refresh="handleRefresh(3)"
@timeout="handleTimeout"
><div class="content-text">已下拉{{ refreshCount3 }}次</div></t-pull-down-refresh
Expand All @@ -61,34 +56,27 @@ export default defineComponent({
const refreshCount3 = ref(0);
const handleRefresh = (value: any) => {
if (value === 1) {
refreshing1.value = true;
setTimeout(() => {
handleChangeRefreshing1(false);
refreshing1.value = false;
refreshCount1.value = 1 + refreshCount1.value;
}, 1000);
} else if (value === 2) {
refreshing2.value = true;
setTimeout(() => {
handleChangeRefreshing2(false);
refreshing2.value = false;
refreshCount2.value = 1 + refreshCount2.value;
}, 1000);
} else {
refreshing3.value = true;
setTimeout(() => {
refreshing3.value = false;
refreshCount3.value = 1 + refreshCount3.value;
}, 3000);
}, 2000);
}
};
const handleTimeout = () => {
Toast('已超时');
refreshCount3.value = 1 + refreshCount3.value;
};
const handleChangeRefreshing1 = (value: boolean) => {
refreshing1.value = value;
};
const handleChangeRefreshing2 = (value: boolean) => {
refreshing2.value = value;
};
const handleChangeRefreshing3 = (value: boolean) => {
refreshing3.value = value;
};
return {
refreshing1,
Expand All @@ -99,9 +87,6 @@ export default defineComponent({
refreshCount3,
handleRefresh,
handleTimeout,
handleChangeRefreshing1,
handleChangeRefreshing2,
handleChangeRefreshing3,
};
},
data() {
Expand Down
17 changes: 7 additions & 10 deletions src/pull-down-refresh/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import { TdPullDownRefreshProps } from './type';
import { PropType } from 'vue';

export default {
/** 加载中下拉高度,如果值为数字则单位是:'px' */
modelValue: {
type: Boolean,
},
/** 加载中下拉高度 */
loadingBarHeight: {
type: [String, Number] as PropType<TdPullDownRefreshProps['loadingBarHeight']>,
type: Number,
default: 50,
},
/** 加载loading样式 */
Expand All @@ -22,22 +25,16 @@ export default {
type: Array as PropType<TdPullDownRefreshProps['loadingTexts']>,
default: (): TdPullDownRefreshProps['loadingTexts'] => [],
},
/** 最大下拉高度,如果值为数字则单位是:'px' */
/** 最大下拉高度 */
maxBarHeight: {
type: [String, Number] as PropType<TdPullDownRefreshProps['maxBarHeight']>,
type: Number,
default: 80,
},
/** 刷新超时时间 */
refreshTimeout: {
type: Number,
default: 3000,
},
/** 组件状态,值为 `true` 表示下拉状态,值为 `false` 表示收起状态 */
value: Boolean,
/** 组件状态,值为 `true` 表示下拉状态,值为 `false` 表示收起状态,非受控属性 */
defaultValue: Boolean,
/** 下拉或收起时触发,用户手势往下滑动触发下拉状态,手势松开触发收起状态 */
onChange: Function as PropType<TdPullDownRefreshProps['onChange']>,
/** 结束下拉时触发 */
onRefresh: Function as PropType<TdPullDownRefreshProps['onRefresh']>,
/** 刷新超时触发 */
Expand Down
10 changes: 3 additions & 7 deletions src/pull-down-refresh/pull-down-refresh.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
loadingBarHeight | String / Number | 50 | 加载中下拉高度,如果值为数字则单位是:'px' | N
loadingProps | Object | - | 加载loading样式。TS 类型:`LoadingProps`[Loading API Documents](./loading?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/pull-down-refresh/type.ts) | N
loadingBarHeight | Number | 50 | 加载中下拉高度 | N
loadingProps | Object | - | 加载loading样式。TS 类型:`TdLoadingProps`[Loading API Documents](./loading?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/pull-down-refresh/type.ts) | N
loadingTexts | Array | [] | 提示语,组件内部默认值为 ['下拉刷新', '松手刷新', '正在刷新', '刷新完成']。TS 类型:`string[]` | N
maxBarHeight | String / Number | 80 | 最大下拉高度,如果值为数字则单位是:'px' | N
maxBarHeight | Number | 80 | 最大下拉高度 | N
refreshTimeout | Number | 3000 | 刷新超时时间 | N
value | Boolean | false | 组件状态,值为 `true` 表示下拉状态,值为 `false` 表示收起状态。支持语法糖 `v-model``v-model:value` | N
defaultValue | Boolean | false | 组件状态,值为 `true` 表示下拉状态,值为 `false` 表示收起状态。非受控属性 | N
onChange | Function | | TS 类型:`(value: boolean) => void`<br/>下拉或收起时触发,用户手势往下滑动触发下拉状态,手势松开触发收起状态 | N
onRefresh | Function | | TS 类型:`() => void`<br/>结束下拉时触发 | N
onTimeout | Function | | TS 类型:`() => void`<br/>刷新超时触发 | N

### PullDownRefresh Events

名称 | 参数 | 描述
-- | -- | --
change | `(value: boolean)` | 下拉或收起时触发,用户手势往下滑动触发下拉状态,手势松开触发收起状态
refresh | - | 结束下拉时触发
timeout | - | 刷新超时触发
Loading

0 comments on commit 7f54648

Please sign in to comment.