提交 d2dc1d20 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新 自定义下拉上拉效果 模板

上级 27cdd156
...@@ -657,8 +657,8 @@ ...@@ -657,8 +657,8 @@
{ {
"path": "pages/template/scroll-fold-nav/scroll-fold-nav", "path": "pages/template/scroll-fold-nav/scroll-fold-nav",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTextStyle":"black" "navigationBarTextStyle": "black"
} }
}, },
{ {
...@@ -689,16 +689,22 @@ ...@@ -689,16 +689,22 @@
{ {
"path": "pages/template/scroll-fold-nav2/scroll-fold-nav2", "path": "pages/template/scroll-fold-nav2/scroll-fold-nav2",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/template/calendar/calendar",
"style": {
"navigationBarTitleText": "日历",
"enablePullDownRefresh": false
}
}, {
"path": "pages/template/custom-refresher/custom-refresher",
"style": {
"navigationBarTitleText": "自定义下拉刷新(原生实现)",
"enablePullDownRefresh": false
} }
},
{
"path" : "pages/template/calendar/calendar",
"style" :
{
"navigationBarTitleText": "日历",
"enablePullDownRefresh": false
}
} }
], ],
"globalStyle": { "globalStyle": {
...@@ -715,8 +721,7 @@ ...@@ -715,8 +721,7 @@
"selectedColor": "#007AFF", "selectedColor": "#007AFF",
"borderStyle": "black", "borderStyle": "black",
"backgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8",
"list": [ "list": [{
{
"pagePath": "pages/tabBar/component", "pagePath": "pages/tabBar/component",
"iconPath": "static/component.png", "iconPath": "static/component.png",
"selectedIconPath": "static/componentHL.png", "selectedIconPath": "static/componentHL.png",
...@@ -745,12 +750,10 @@ ...@@ -745,12 +750,10 @@
"condition": { "condition": {
//模式配置,仅开发期间生效 //模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项) "current": 0, //当前激活的模式(list 的索引项)
"list": [ "list": [{
{ "name": "", //模式名称
"name": "", //模式名称 "path": "", //启动页面,必选
"path": "", //启动页面,必选 "query": "" //启动参数,在页面的onLoad函数里面得到
"query": "" //启动参数,在页面的onLoad函数里面得到 }]
}
]
} }
} }
\ No newline at end of file
<template> <template>
<view class="root"> <view class="root">
<view class="top-box"> <view class="top-box">
<text class="top-box-text">可通过slot自定义,上拉加载下来刷新效果示例</text> <text class="top-box-text">可通过slot自定义,上拉加载下来刷新效果示例</text>
<text class="top-box-text">已知问题:因不支持通过ref 调用组件内的方法,本示例在下拉触发刷新方法时,1秒后“组件内”直接调用刷新完成接口,上拉加载同理。后续会修复</text> </view>
</view>
<custom-pull :height="300" width="750rpx" :refreshBoxHeight="60" :refreshThreshold="60" :refreshHoldHeight="60" <custom-pull :height="300" width="750rpx" :refreshBoxHeight="60" :refreshThreshold="60" :refreshHoldHeight="60"
:loadingBoxHeight="30" :loadingThreshold="20" :loadingHoldHeight="30" @loading="loading" @refresh="refresh" :loadingBoxHeight="30" :loadingThreshold="20" :loadingHoldHeight="30" @loading="loading" @refresh="refresh"
...@@ -11,17 +10,16 @@ ...@@ -11,17 +10,16 @@
<template v-slot:refresh-box="scope"> <template v-slot:refresh-box="scope">
<view class="refresh-box"> <view class="refresh-box">
<image class="logo" src="/static/logo.png" mode="widthFix"></image> <image class="logo" src="/static/uni.png" mode="widthFix"></image>
<text class="tip-text" v-if="scope.get('refreshState')== 0">继续下拉执行刷新(slot)</text> <text class="tip-text" v-if="scope.get('refreshState')== 0">继续下拉执行刷新(slot)</text>
<text class="tip-text" v-if="scope.get('refreshState')== 1">释放立即刷新</text> <text class="tip-text" v-if="scope.get('refreshState')== 1">释放立即刷新</text>
<text class="tip-text" v-if="scope.get('refreshState')== 2">刷新中</text> <text class="tip-text" v-if="scope.get('refreshState')== 2">刷新中</text>
<text class="tip-text" v-if="scope.get('refreshState')== 3">刷新完成</text> <text class="tip-text" v-if="scope.get('refreshState')== 3">刷新完成</text>
<!-- 可基于拖动距离实现互动性更加强的效果 --> <!-- 可基于拖动距离实现互动性更加强的效果 -->
<!-- <text class="tip-text">拖动的距离:{{scope.get('pullingDistance')}}</text> --> <!-- <text class="tip-text">拖动的距离:{{scope.get('pullingDistance')}}</text> -->
</view> </view>
</template> </template>
<view v-for="i in 8" class="item"> <view v-for="i in 8" class="item">
item-{{i}} item-{{i}}
</view> </view>
...@@ -31,7 +29,7 @@ ...@@ -31,7 +29,7 @@
<text class="tip-text" v-if="scope.get('loadingState')== 0">继续上拉加载更多(slot)</text> <text class="tip-text" v-if="scope.get('loadingState')== 0">继续上拉加载更多(slot)</text>
<text class="tip-text" v-if="scope.get('loadingState')== 1">释放立即加载更多</text> <text class="tip-text" v-if="scope.get('loadingState')== 1">释放立即加载更多</text>
<text class="tip-text" v-if="scope.get('loadingState')== 2">加载中...</text> <text class="tip-text" v-if="scope.get('loadingState')== 2">加载中...</text>
<text class="tip-text" v-if="scope.get('loadingState')== 3">加载完成</text> <text class="tip-text" v-if="scope.get('loadingState')== 3">加载完成</text>
<!-- 可基于拖动距离实现互动性更加强的效果 --> <!-- 可基于拖动距离实现互动性更加强的效果 -->
<!-- <text>拖动的距离:{{scope.get('pullingDistance')}}</text> --> <!-- <text>拖动的距离:{{scope.get('pullingDistance')}}</text> -->
</view> </view>
...@@ -53,18 +51,18 @@ ...@@ -53,18 +51,18 @@
return { return {
} }
}, },
onLoad() { onReady() {
console.log('this.$refs["custom-pull"]', this.$refs["custom-pull"]); // console.log('this.$refs["custom-pull"]', this.$refs["custom-pull"] as ComponentPublicInstance);
}, },
methods: { methods: {
loading() { loading() {
setTimeout(() => { setTimeout(() => {
// this.$refs["custom-pull"].endLoading() //暂不支持,内部模拟实现 (this.$refs["custom-pull"] as ComponentPublicInstance).$callMethod('endLoading')
}, 1000); }, 1000);
}, },
refresh() { refresh() {
setTimeout(() => { setTimeout(() => {
// this.$refs["custom-pull"].endRefresh() //暂不支持,内部模拟实现 (this.$refs["custom-pull"] as ComponentPublicInstance).$callMethod('endRefresh')
}, 1000); }, 1000);
} }
} }
...@@ -75,13 +73,13 @@ ...@@ -75,13 +73,13 @@
.root { .root {
flex: 1; flex: 1;
background-color: #FFF; background-color: #FFF;
} }
.top-box{ .top-box{
padding: 15px 5px; padding: 15px 5px;
} }
.top-box-text{ .top-box-text{
font-size: 14px; font-size: 14px;
color: #888; color: #888;
} }
.custom-pull { .custom-pull {
...@@ -97,7 +95,7 @@ ...@@ -97,7 +95,7 @@
.logo { .logo {
width: 30px; width: 30px;
height: 30px; height: 30px;
margin-top: 3px; margin-top: 3px;
} }
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
:style="{'height':height+loadingBoxHeight+refreshBoxHeight+'px',width,'transform':'translateY('+(y-refreshBoxHeight-3)+'px)'}"> :style="{'height':height+loadingBoxHeight+refreshBoxHeight+'px',width,'transform':'translateY('+(y-refreshBoxHeight-3)+'px)'}">
<view class="refresh-box" :style="{height:refreshBoxHeight+'px'}"> <view class="refresh-box" :style="{height:refreshBoxHeight+'px'}">
<slot name="refresh-box" :refreshState="refreshState" :pullingDistance="y"></slot> <slot name="refresh-box" :refreshState="refreshState" :pullingDistance="y"></slot>
</view> </view>
<!-- <view v-if="refreshState == 0">继续下拉执行刷新</view> <!-- <view v-if="refreshState == 0">继续下拉执行刷新</view>
<view v-if="refreshState == 1">释放立即刷新</view> <view v-if="refreshState == 1">释放立即刷新</view>
<view v-if="refreshState == 2">刷新中...</view> <view v-if="refreshState == 2">刷新中...</view>
...@@ -92,13 +92,15 @@ ...@@ -92,13 +92,15 @@
touchstart(e : TouchEvent) { touchstart(e : TouchEvent) {
sY = e.touches[0].screenY sY = e.touches[0].screenY
}, },
touchmove(e : TouchEvent) { touchmove(e : TouchEvent) {
if ( if (
// 滚动条不在顶部,也不是触底 !(
scrollTop != 0 && !this.scrollInBottom || (scrollTop == 0 && this.refreshState == 0) ||
// 正在刷新中,或者加载更多中 (this.scrollInBottom == true && this.loadingState == 0)
this.refreshState != 0 && this.loadingState != 0 )
) { ) {
// console.log('this.scrollInBottom == true && this.loadingState == 0')
// console.log(this.scrollInBottom,this.loadingState)
return return
} }
...@@ -150,9 +152,12 @@ ...@@ -150,9 +152,12 @@
} }
}, },
onScroll(e : ScrollEvent) { onScroll(e : ScrollEvent) {
console.log('ScrollViewScroll-currentTarget', e.currentTarget); // console.log('ScrollEvent-currentTarget', e.currentTarget);
scrollTop = e.detail.scrollTop // console.log('e.detail.scrollTop',Math.floor(e.detail.scrollTop));
this.scrollInBottom = (scrollTop + this.height) == e.detail.scrollHeight scrollTop = Math.floor(e.detail.scrollTop)
// console.log('(scrollTop + this.height) == e.detail.scrollHeight',(scrollTop + this.height) == e.detail.scrollHeight)
// console.log('(scrollTop + this.height) == e.detail.scrollHeight',scrollTop,this.height,e.detail.scrollHeight)
this.scrollInBottom = (scrollTop + this.height) == Math.floor(e.detail.scrollHeight)
}, },
endRefresh() { endRefresh() {
this.refreshState = 3 this.refreshState = 3
...@@ -173,9 +178,7 @@ ...@@ -173,9 +178,7 @@
</script> </script>
<style scoped> <style scoped>
.pull-box-root { .pull-box-root {}
}
.pull-box {} .pull-box {}
/* .loading-box { /* .loading-box {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册