Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
441894c7
U
uni-app
项目概览
DCloud
/
uni-app
29 天 前同步成功
通知
702
Star
38704
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
441894c7
编写于
7月 05, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: scroll-view 刷新状态异常 question/124430
上级
9ed205f1
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
67 addition
and
41 deletion
+67
-41
src/core/view/components/scroll-view/index.vue
src/core/view/components/scroll-view/index.vue
+67
-41
未找到文件。
src/core/view/components/scroll-view/index.vue
浏览文件 @
441894c7
...
...
@@ -26,6 +26,7 @@
<div
class=
"uni-scroll-view-refresh-inner"
>
<svg
v-if=
"refreshState=='pulling'"
key=
"refresh__icon"
:style=
"
{'transform': 'rotate('+ refreshRotate +'deg)'}"
fill="#2BD009"
class="uni-scroll-view-refresh__icon"
...
...
@@ -41,6 +42,7 @@
</svg>
<svg
v-if=
"refreshState=='refreshing'"
key=
"refresh__spinner"
class=
"uni-scroll-view-refresh__spinner"
width=
"24"
height=
"24"
...
...
@@ -205,11 +207,15 @@ export default {
}
var
touchStart
=
null
var
needStop
=
null
let
toUpperNumber
=
0
// 容器触顶时,此时鼠标Y轴位置
let
triggerAbort
=
false
let
beforeRefreshing
=
false
this
.
__handleTouchMove
=
function
(
event
)
{
var
x
=
event
.
touches
[
0
].
pageX
var
y
=
event
.
touches
[
0
].
pageY
var
main
=
self
.
$refs
.
main
if
(
needStop
===
null
)
{
if
(
Math
.
abs
(
x
-
touchStart
.
x
)
>
Math
.
abs
(
y
-
touchStart
.
y
))
{
// 横向滑动
if
(
self
.
scrollX
)
{
...
...
@@ -227,9 +233,10 @@ export default {
}
else
{
// 纵向滑动
if
(
self
.
scrollY
)
{
if
(
main
.
scrollTop
===
0
&&
y
>
touchStart
.
y
)
{
needStop
=
false
return
if
(
self
.
refresherEnabled
&&
main
.
scrollTop
===
0
&&
y
>
touchStart
.
y
)
{
needStop
=
true
// 刷新时,阻止页面滚动
if
(
event
.
cancelable
!==
false
)
event
.
preventDefault
()
}
else
if
(
main
.
scrollHeight
===
main
.
offsetHeight
+
main
.
scrollTop
&&
y
<
touchStart
.
y
)
{
needStop
=
false
return
...
...
@@ -239,27 +246,39 @@ export default {
needStop
=
false
}
}
}
if
(
needStop
)
{
event
.
stopPropagation
()
}
if
(
self
.
refresherEnabled
&&
self
.
refreshState
===
'
pulling
'
)
{
const
dy
=
y
-
touchStart
.
y
self
.
refresherHeight
=
dy
let
rotate
=
dy
/
self
.
refresherThreshold
if
(
rotate
>
1
)
{
rotate
=
1
}
else
{
rotate
=
rotate
*
360
if
(
main
.
scrollTop
===
0
&&
event
.
touches
.
length
===
1
)
{
// 如果容器滑动到达顶端,则进入下拉状态
self
.
refreshState
=
'
pulling
'
}
self
.
refreshRotate
=
rotate
if
(
self
.
refresherEnabled
&&
self
.
refreshState
===
'
pulling
'
)
{
const
dy
=
y
-
touchStart
.
y
if
(
toUpperNumber
===
0
)
{
toUpperNumber
=
y
}
if
(
!
beforeRefreshing
)
{
self
.
refresherHeight
=
y
-
toUpperNumber
// 之前为刷新状态则不再触发pulling
if
(
self
.
refresherHeight
>
0
)
{
triggerAbort
=
true
self
.
$trigger
(
'
refresherpulling
'
,
event
,
{
deltaY
:
dy
})
}
}
else
{
self
.
refresherHeight
=
dy
+
self
.
refresherThreshold
// 如果之前在刷新状态,则不触发刷新中断
triggerAbort
=
false
}
const
route
=
self
.
refresherHeight
/
self
.
refresherThreshold
self
.
refreshRotate
=
(
route
>
1
?
1
:
route
)
*
360
}
}
this
.
__handleTouchStart
=
function
(
event
)
{
...
...
@@ -267,14 +286,10 @@ export default {
disableScrollBounce
({
disable
:
true
})
needStop
=
null
touchStart
=
{
x
:
event
.
touches
[
0
].
pageX
,
y
:
event
.
touches
[
0
].
pageY
}
if
(
self
.
refresherEnabled
&&
self
.
refreshState
!==
'
refreshing
'
&&
self
.
$refs
.
main
.
scrollTop
===
0
)
{
self
.
refreshState
=
'
pulling
'
}
}
}
this
.
__handleTouchEnd
=
function
(
event
)
{
...
...
@@ -283,14 +298,24 @@ export default {
disable
:
false
})
if
(
self
.
refresherHeight
>=
self
.
refresherThreshold
)
{
self
.
refresherHeight
=
self
.
refresherThreshold
self
.
refreshState
=
'
refreshing
'
// 之前是刷新状态则不再触发刷新
if
(
beforeRefreshing
)
return
beforeRefreshing
=
true
self
.
_setRefreshState
(
'
refreshing
'
)
}
else
{
self
.
refresherHeight
=
0
beforeRefreshing
=
false
self
.
refreshState
=
'
refresherabort
'
self
.
refresherHeight
=
toUpperNumber
=
0
if
(
triggerAbort
)
{
triggerAbort
=
false
self
.
$trigger
(
'
refresherabort
'
,
event
,
{})
}
}
}
this
.
$refs
.
main
.
addEventListener
(
'
touchstart
'
,
this
.
__handleTouchStart
,
passiveOptions
)
this
.
$refs
.
main
.
addEventListener
(
'
touchmove
'
,
this
.
__handleTouchMove
,
passiveOptions
)
this
.
$refs
.
main
.
addEventListener
(
'
touchmove
'
,
this
.
__handleTouchMove
)
this
.
$refs
.
main
.
addEventListener
(
'
scroll
'
,
this
.
__handleScroll
,
supportsPassive
?
{
passive
:
false
}
:
false
)
...
...
@@ -567,7 +592,8 @@ uni-scroll-view[hidden] {
height
:
40px
;
border-radius
:
50%
;
background-color
:
#fff
;
box-shadow
:
0
1px
6px
rgba
(
0
,
0
,
0
,
.117647
),
0
1px
4px
rgba
(
0
,
0
,
0
,
.117647
);
box-shadow
:
0
1px
6px
rgba
(
0
,
0
,
0
,
0.117647
),
0
1px
4px
rgba
(
0
,
0
,
0
,
0.117647
);
}
.uni-scroll-view-refresh__spinner
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录