Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
0ab1f949
G
Graphic Ui
项目概览
OpenHarmony
/
Graphic Ui
大约 1 年 前同步成功
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Graphic Ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0ab1f949
编写于
8月 02, 2021
作者:
O
openharmony_ci
提交者:
Gitee
8月 02, 2021
浏览文件
操作
浏览文件
下载
差异文件
!341 修复UIList滑到端点后再反复滑出现严重回弹问题
Merge pull request !341 from YueBiang/drag_master
上级
a71bdfe4
4bab5cdb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
12 deletion
+33
-12
frameworks/components/ui_abstract_scroll.cpp
frameworks/components/ui_abstract_scroll.cpp
+5
-4
frameworks/components/ui_list.cpp
frameworks/components/ui_list.cpp
+13
-3
frameworks/components/ui_scroll_view.cpp
frameworks/components/ui_scroll_view.cpp
+12
-3
interfaces/kits/components/ui_abstract_scroll.h
interfaces/kits/components/ui_abstract_scroll.h
+3
-2
未找到文件。
frameworks/components/ui_abstract_scroll.cpp
浏览文件 @
0ab1f949
...
...
@@ -198,7 +198,7 @@ void UIAbstractScroll::StopAnimator()
isDragging_
=
false
;
}
bool
UIAbstractScroll
::
DragThrowAnimator
(
Point
currentPos
,
Point
lastPos
)
bool
UIAbstractScroll
::
DragThrowAnimator
(
Point
currentPos
,
Point
lastPos
,
uint8_t
dragDirection
)
{
if
(
!
throwDrag_
&&
(
reboundSize_
==
0
))
{
return
false
;
...
...
@@ -206,7 +206,7 @@ bool UIAbstractScroll::DragThrowAnimator(Point currentPos, Point lastPos)
int16_t
dragDistanceX
=
0
;
int16_t
dragDistanceY
=
0
;
if
(
throwDrag_
)
{
CalculateDragDistance
(
currentPos
,
lastPos
,
dragDistanceX
,
dragDistanceY
);
CalculateDragDistance
(
currentPos
,
lastPos
,
dragDi
rection
,
dragDi
stanceX
,
dragDistanceY
);
}
if
(
reboundSize_
!=
0
)
{
CalculateReboundDistance
(
dragDistanceX
,
dragDistanceY
);
...
...
@@ -230,14 +230,15 @@ void UIAbstractScroll::StartAnimator(int16_t dragDistanceX, int16_t dragDistance
void
UIAbstractScroll
::
CalculateDragDistance
(
Point
currentPos
,
Point
lastPos
,
uint8_t
dragDirection
,
int16_t
&
dragDistanceX
,
int16_t
&
dragDistanceY
)
{
if
((
direction_
==
VERTICAL
)
||
(
direction_
==
HORIZONTAL_AND_VERTICAL
))
{
dragDistanceY
=
(
currentPos
.
y
-
lastPos
.
y
)
*
DRAG_DISTANCE_COEFFICIENT
;
if
(
dragDistanceY
>
0
)
{
if
(
dragDistanceY
>
0
||
(
dragDistanceY
==
0
&&
dragDirection
==
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
)
)
{
dragDistanceY
+=
GetMaxDeltaY
()
*
GetSwipeACCLevel
()
/
DRAG_ACC_FACTOR
;
}
else
{
}
else
if
(
dragDistanceY
<
0
||
(
dragDistanceY
==
0
&&
dragDirection
==
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
))
{
dragDistanceY
-=
GetMaxDeltaY
()
*
GetSwipeACCLevel
()
/
DRAG_ACC_FACTOR
;
}
}
...
...
frameworks/components/ui_list.cpp
浏览文件 @
0ab1f949
...
...
@@ -223,7 +223,7 @@ bool UIList::OnDragEndEvent(const DragEvent& event)
current
=
event
.
GetCurrentPos
();
}
isReCalculateDragEnd_
=
false
;
if
(
!
DragThrowAnimator
(
current
,
last
))
{
if
(
!
DragThrowAnimator
(
current
,
last
,
event
.
GetDragDirection
()
))
{
if
(
scrollListener_
&&
(
scrollListener_
->
GetScrollState
()
==
ListScrollListener
::
SCROLL_STATE_MOVE
))
{
scrollListener_
->
SetScrollState
(
ListScrollListener
::
SCROLL_STATE_STOP
);
scrollListener_
->
OnScrollEnd
(
onSelectedIndex_
,
onSelectedView_
);
...
...
@@ -267,6 +267,16 @@ bool UIList::OnRotateEndEvent(const RotateEvent& event)
needVibration_
=
false
;
isReCalculateDragEnd_
=
false
;
for
(
uint8_t
i
=
0
;
i
<
MAX_DELTA_Y_SIZE
;
i
++
)
{
lastDeltaY_
[
i
]
=
0
;
}
uint8_t
dir
;
if
(
direction_
==
VERTICAL
)
{
dir
=
(
lastRotateLen_
>=
0
)
?
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
:
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
;
}
else
{
dir
=
(
lastRotateLen_
>=
0
)
?
DragEvent
::
DIRECTION_LEFT_TO_RIGHT
:
DragEvent
::
DIRECTION_RIGHT_TO_LEFT
;
}
bool
triggerAnimator
=
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetWidth
()
/
threshold_
))
||
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetHeight
()
/
threshold_
));
if
(
throwDrag_
&&
triggerAnimator
)
{
...
...
@@ -276,9 +286,9 @@ bool UIList::OnRotateEndEvent(const RotateEvent& event)
}
else
{
current
=
{
lastRotateLen_
,
0
};
}
DragThrowAnimator
(
current
,
{
0
,
0
});
DragThrowAnimator
(
current
,
{
0
,
0
}
,
dir
);
}
else
{
DragThrowAnimator
({
0
,
0
},
{
0
,
0
});
DragThrowAnimator
({
0
,
0
},
{
0
,
0
}
,
dir
);
}
lastRotateLen_
=
0
;
return
UIView
::
OnRotateEndEvent
(
event
);
...
...
frameworks/components/ui_scroll_view.cpp
浏览文件 @
0ab1f949
...
...
@@ -67,7 +67,7 @@ bool UIScrollView::OnDragEndEvent(const DragEvent& event)
current
=
event
.
GetCurrentPos
();
}
if
(
!
DragThrowAnimator
(
current
,
last
))
{
if
(
!
DragThrowAnimator
(
current
,
last
,
event
.
GetDragDirection
()
))
{
if
(
scrollListener_
&&
(
scrollListener_
->
GetScrollState
()
==
OnScrollListener
::
SCROLL_STATE_MOVE
))
{
scrollListener_
->
OnScrollEnd
();
scrollListener_
->
SetScrollState
(
OnScrollListener
::
SCROLL_STATE_STOP
);
...
...
@@ -143,6 +143,15 @@ bool UIScrollView::OnRotateEvent(const RotateEvent& event)
bool
UIScrollView
::
OnRotateEndEvent
(
const
RotateEvent
&
event
)
{
for
(
uint8_t
i
=
0
;
i
<
MAX_DELTA_Y_SIZE
;
i
++
)
{
lastDeltaY_
[
i
]
=
0
;
}
uint8_t
dir
;
if
(
direction_
==
VERTICAL
)
{
dir
=
(
lastRotateLen_
>=
0
)
?
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
:
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
;
}
else
{
dir
=
(
lastRotateLen_
>=
0
)
?
DragEvent
::
DIRECTION_LEFT_TO_RIGHT
:
DragEvent
::
DIRECTION_RIGHT_TO_LEFT
;
}
bool
triggerAnimator
=
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetWidth
()
/
threshold_
))
||
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetHeight
()
/
threshold_
));
if
(
throwDrag_
&&
triggerAnimator
)
{
...
...
@@ -152,9 +161,9 @@ bool UIScrollView::OnRotateEndEvent(const RotateEvent& event)
}
else
{
current
=
{
lastRotateLen_
,
0
};
}
DragThrowAnimator
(
current
,
{
0
,
0
});
DragThrowAnimator
(
current
,
{
0
,
0
}
,
dir
);
}
else
{
DragThrowAnimator
({
0
,
0
},
{
0
,
0
});
DragThrowAnimator
({
0
,
0
},
{
0
,
0
}
,
dir
);
}
lastRotateLen_
=
0
;
return
UIView
::
OnRotateEndEvent
(
event
);
...
...
interfaces/kits/components/ui_abstract_scroll.h
浏览文件 @
0ab1f949
...
...
@@ -348,7 +348,7 @@ protected:
int16_t
previousValueY_
;
};
bool
DragThrowAnimator
(
Point
currentPos
,
Point
lastPos
);
bool
DragThrowAnimator
(
Point
currentPos
,
Point
lastPos
,
uint8_t
dragDirection
);
virtual
void
StopAnimator
();
virtual
bool
DragXInner
(
int16_t
distance
)
=
0
;
virtual
bool
DragYInner
(
int16_t
distance
)
=
0
;
...
...
@@ -358,7 +358,8 @@ protected:
deltaYIndex_
++
;
}
void
CalculateDragDistance
(
Point
currentPos
,
Point
lastPos
,
int16_t
&
dragDistanceX
,
int16_t
&
dragDistanceY
);
void
CalculateDragDistance
(
Point
currentPos
,
Point
lastPos
,
uint8_t
dragDirection
,
int16_t
&
dragDistanceX
,
int16_t
&
dragDistanceY
);
void
StartAnimator
(
int16_t
dragDistanceX
,
int16_t
dragDistanceY
);
virtual
void
CalculateReboundDistance
(
int16_t
&
dragDistanceX
,
int16_t
&
dragDistanceY
)
{};
int16_t
GetMaxDeltaY
()
const
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录