Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
良好的行为成为习惯
uni-app
提交
ce314ac1
U
uni-app
项目概览
良好的行为成为习惯
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ce314ac1
编写于
9月 28, 2021
作者:
M
mehaotian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(h5): scroll-view 修改回滚
上级
66f5e3b4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
17 addition
and
72 deletion
+17
-72
src/core/view/components/scroll-view/index.vue
src/core/view/components/scroll-view/index.vue
+17
-72
未找到文件。
src/core/view/components/scroll-view/index.vue
浏览文件 @
ce314ac1
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
ref=
"refresherinner"
ref=
"refresherinner"
:style=
"
{
:style=
"
{
'background-color': refresherBackground,
'background-color': refresherBackground,
height: refresher
Threshold
+ 'px',
height: refresher
Height
+ 'px',
}"
}"
class="uni-scroll-view-refresher"
class="uni-scroll-view-refresher"
>
>
...
@@ -158,13 +158,13 @@ export default {
...
@@ -158,13 +158,13 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
lastScrollTop
:
this
.
scrollTopNumber
||
0
,
lastScrollTop
:
this
.
scrollTopNumber
,
lastScrollLeft
:
this
.
scrollLeftNumber
||
0
,
lastScrollLeft
:
this
.
scrollLeftNumber
,
lastScrollToUpperTime
:
0
,
lastScrollToUpperTime
:
0
,
lastScrollToLowerTime
:
0
,
lastScrollToLowerTime
:
0
,
refresherHeight
:
0
,
refresherHeight
:
0
,
refreshRotate
:
0
,
refreshRotate
:
0
,
refreshState
:
'
restore
'
refreshState
:
''
}
}
},
},
computed
:
{
computed
:
{
...
@@ -225,6 +225,7 @@ export default {
...
@@ -225,6 +225,7 @@ export default {
var
x
=
event
.
touches
[
0
].
pageX
var
x
=
event
.
touches
[
0
].
pageX
var
y
=
event
.
touches
[
0
].
pageY
var
y
=
event
.
touches
[
0
].
pageY
var
main
=
self
.
$refs
.
main
var
main
=
self
.
$refs
.
main
if
(
Math
.
abs
(
x
-
touchStart
.
x
)
>
Math
.
abs
(
y
-
touchStart
.
y
))
{
if
(
Math
.
abs
(
x
-
touchStart
.
x
)
>
Math
.
abs
(
y
-
touchStart
.
y
))
{
// 横向滑动
// 横向滑动
if
(
self
.
scrollX
)
{
if
(
self
.
scrollX
)
{
...
@@ -245,13 +246,10 @@ export default {
...
@@ -245,13 +246,10 @@ export default {
}
else
{
}
else
{
// 纵向滑动
// 纵向滑动
if
(
self
.
scrollY
)
{
if
(
self
.
scrollY
)
{
if
(
main
.
scrollTop
===
0
&&
y
>
=
touchStart
.
y
)
{
if
(
main
.
scrollTop
===
0
&&
y
>
touchStart
.
y
)
{
needStop
=
false
needStop
=
false
// 刷新时,阻止页面滚动
// 刷新时,阻止页面滚动
if
(
self
.
refresherEnabled
&&
event
.
cancelable
!==
false
)
{
if
(
self
.
refresherEnabled
&&
event
.
cancelable
!==
false
)
{
if
(
self
.
refreshState
!==
'
pulling
'
&&
self
.
refreshState
!==
'
refreshing
'
)
{
self
.
refreshState
=
'
pulling
'
}
event
.
preventDefault
()
event
.
preventDefault
()
}
}
}
else
if
(
}
else
if
(
...
@@ -267,71 +265,42 @@ export default {
...
@@ -267,71 +265,42 @@ export default {
needStop
=
false
needStop
=
false
}
}
}
}
if
(
needStop
)
{
if
(
needStop
)
{
event
.
stopPropagation
()
event
.
stopPropagation
()
}
}
// 刷新中
if
(
self
.
refresherEnabled
&&
self
.
refreshState
===
'
refreshing
'
)
{
if
(
main
.
scrollTop
===
0
&&
event
.
touches
.
length
===
1
)
{
if
(
event
.
cancelable
!==
false
)
{
// 如果容器滑动到达顶端,则进入下拉状态
event
.
preventDefault
()
self
.
refreshState
=
'
pulling
'
}
// this.refresherThreshold
let
dy
=
y
-
touchStart
.
y
+
self
.
refresherThreshold
if
(
dy
<=
0
)
{
dy
=
0
// 刷新时,阻止页面滚动
}
if
(
dy
>
self
.
refresherThreshold
)
{
self
.
refresherHeight
=
Math
.
floor
(
dy
*
0.16
)
+
self
.
refresherThreshold
}
else
{
self
.
refresherHeight
=
dy
}
const
transform
=
'
translateY(
'
+
self
.
refresherHeight
+
'
px) translateZ(0)
'
self
.
$refs
.
content
.
style
.
transform
=
transform
self
.
$refs
.
content
.
style
.
webkitTransform
=
transform
// return
}
}
let
_dy
=
0
if
(
self
.
refresherEnabled
&&
self
.
refreshState
===
'
pulling
'
)
{
if
(
self
.
refresherEnabled
&&
self
.
refreshState
===
'
pulling
'
)
{
if
(
event
.
cancelable
!==
false
)
{
event
.
preventDefault
()
}
const
dy
=
y
-
touchStart
.
y
const
dy
=
y
-
touchStart
.
y
if
(
self
.
toUpperNumber
===
0
)
{
if
(
self
.
toUpperNumber
===
0
)
{
self
.
toUpperNumber
=
y
self
.
toUpperNumber
=
y
}
}
if
(
!
self
.
beforeRefreshing
)
{
if
(
!
self
.
beforeRefreshing
)
{
_dy
=
y
-
self
.
toUpperNumber
self
.
refresherHeight
=
y
-
self
.
toUpperNumber
// 之前为刷新状态则不再触发pulling
// 之前为刷新状态则不再触发pulling
if
(
_dy
>
0
)
{
if
(
self
.
refresherHeight
>
0
)
{
self
.
triggerAbort
=
true
self
.
triggerAbort
=
true
self
.
$trigger
(
'
refresherpulling
'
,
event
,
{
self
.
$trigger
(
'
refresherpulling
'
,
event
,
{
deltaY
:
dy
deltaY
:
dy
})
})
}
}
}
else
{
}
else
{
_dy
=
dy
+
self
.
refresherThreshold
self
.
refresherHeight
=
dy
+
self
.
refresherThreshold
// 如果之前在刷新状态,则不触发刷新中断
// 如果之前在刷新状态,则不触发刷新中断
self
.
triggerAbort
=
false
self
.
triggerAbort
=
false
}
}
self
.
refresherHeight
=
Math
.
floor
(
_dy
*
0.16
)
if
(
self
.
refresherHeight
<=
0
)
{
self
.
refresherHeight
=
0
}
const
transform
=
'
translateY(
'
+
self
.
refresherHeight
+
'
px) translateZ(0)
'
self
.
$refs
.
content
.
style
.
transform
=
transform
self
.
$refs
.
content
.
style
.
webkitTransform
=
transform
const
route
=
self
.
refresherHeight
/
self
.
refresherThreshold
const
route
=
self
.
refresherHeight
/
self
.
refresherThreshold
self
.
refreshRotate
=
(
route
>
1
?
1
:
route
)
*
360
self
.
refreshRotate
=
(
route
>
1
?
1
:
route
)
*
360
}
}
}
}
this
.
__handleTouchStart
=
function
(
event
)
{
this
.
__handleTouchStart
=
function
(
event
)
{
self
.
$refs
.
content
.
style
.
transition
=
''
self
.
$refs
.
content
.
style
.
webkitTransition
=
''
if
(
event
.
touches
.
length
===
1
)
{
if
(
event
.
touches
.
length
===
1
)
{
disableScrollBounce
({
disableScrollBounce
({
disable
:
true
disable
:
true
...
@@ -347,21 +316,8 @@ export default {
...
@@ -347,21 +316,8 @@ export default {
disableScrollBounce
({
disableScrollBounce
({
disable
:
false
disable
:
false
})
})
if
(
self
.
refreshState
===
'
refreshing
'
&&
self
.
refresherHeight
<
self
.
refresherThreshold
)
{
self
.
_setRefreshState
(
'
restore
'
)
return
}
if
(
self
.
refresherHeight
>=
self
.
refresherThreshold
)
{
if
(
self
.
refresherHeight
>=
self
.
refresherThreshold
)
{
if
(
self
.
refreshState
!==
'
refreshing
'
)
{
self
.
_setRefreshState
(
'
refreshing
'
)
self
.
_setRefreshState
(
'
refreshing
'
)
}
else
{
const
transform
=
'
translateY(
'
+
self
.
refresherThreshold
+
'
px) translateZ(0)
'
self
.
$refs
.
content
.
style
.
transition
=
'
transform .3s ease-out
'
self
.
$refs
.
content
.
style
.
webkitTransition
=
'
-webkit-transform .3s ease-out
'
self
.
$refs
.
content
.
style
.
transform
=
transform
self
.
$refs
.
content
.
style
.
webkitTransform
=
transform
}
}
else
{
}
else
{
self
.
_setRefreshState
(
'
refresherabort
'
)
self
.
_setRefreshState
(
'
refresherabort
'
)
}
}
...
@@ -677,13 +633,6 @@ export default {
...
@@ -677,13 +633,6 @@ export default {
}
}
break
break
}
}
const
transform
=
'
translateY(
'
+
this
.
refresherHeight
+
'
px) translateZ(0)
'
this
.
$refs
.
content
.
style
.
transition
=
'
transform .3s ease-out
'
this
.
$refs
.
content
.
style
.
webkitTransition
=
'
-webkit-transform .3s ease-out
'
this
.
$refs
.
content
.
style
.
transform
=
transform
this
.
$refs
.
content
.
style
.
webkitTransform
=
transform
this
.
refreshState
=
state
this
.
refreshState
=
state
},
},
getScrollPosition
()
{
getScrollPosition
()
{
...
@@ -718,16 +667,12 @@ uni-scroll-view[hidden] {
...
@@ -718,16 +667,12 @@ uni-scroll-view[hidden] {
}
}
.uni-scroll-view-content
{
.uni-scroll-view-content
{
position
:
relative
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
}
}
.uni-scroll-view-refresher
{
.uni-scroll-view-refresher
{
position
:
absolute
;
position
:
relative
;
left
:
0
;
right
:
0
;
transform
:
translateY
(
-100%
);
overflow
:
hidden
;
overflow
:
hidden
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录