提交 7f0c5467 编写于 作者: O openharmony_ci 提交者: Gitee

!66 fix rotate event bug for UIScrollView

Merge pull request !66 from YueBiang/rotate
......@@ -30,6 +30,8 @@ UIScrollView::UIScrollView()
#if ENABLE_ROTATE_INPUT
rotateFactor_ = 1;
rotateThreshold_ = 4; // 4: which means 25% of half view size
tmpRotateLen_ = 0;
#endif
#if ENABLE_FOCUS_MANAGER
focusable_ = true;
......@@ -106,21 +108,22 @@ bool UIScrollView::OnPressEvent(const PressEvent& event)
#if ENABLE_ROTATE_INPUT
bool UIScrollView::OnRotateEvent(const RotateEvent& event)
{
int16_t tmpRotateLen = static_cast<int16_t>(event.GetRotate() * rotateFactor_);
int16_t midPointX = static_cast<int16_t>(GetWidth() / 2); // 2 : Get the middle point X coord of the view
int16_t midPointY = static_cast<int16_t>(GetHeight() / 2); // 2 : Get the middle point Y coord of the view
Point last, current;
if (!throwDrag_ || ((MATH_ABS(tmpRotateLen) < (midPointX / rotateThreshold_)) &&
(MATH_ABS(tmpRotateLen) < (midPointY / rotateThreshold_)))) {
yScrollable_ ? ScrollBy(0, tmpRotateLen) : ScrollBy(tmpRotateLen, 0);
if (event.GetRotate() == 0) {
DragThrowAnimator(Point {0, 0}, Point {0, 0});
}
} else {
if (throwDrag_ && event.GetRotate() == 0) {
last = Point {midPointX, midPointY};
yScrollable_ ? (current = Point {midPointX, static_cast<int16_t>(midPointY + tmpRotateLen)})
: (current = Point {static_cast<int16_t>(midPointX + tmpRotateLen), midPointY});
yScrollable_ ? (current = Point {midPointX, static_cast<int16_t>(midPointY + tmpRotateLen_)})
: (current = Point {static_cast<int16_t>(midPointX + tmpRotateLen_), midPointY});
DragThrowAnimator(current, last);
tmpRotateLen_ = 0;
} else {
tmpRotateLen_ = static_cast<int16_t>(event.GetRotate() * rotateFactor_);
if (yScrollable_) {
DragYInner(tmpRotateLen_);
} else {
DragXInner(tmpRotateLen_);
}
}
#if ENABLE_MOTOR
MotorFunc motorFunc = FocusManager::GetInstance()->GetMotorFunc();
......@@ -417,4 +420,4 @@ void UIScrollView::StopAnimator()
}
UIAbstractScroll::StopAnimator();
}
} // namespace OHOS
\ No newline at end of file
} // namespace OHOS
......@@ -292,6 +292,9 @@ private:
bool yScrollable_;
int16_t minScrollBarLen_;
OnScrollListener* scrollListener_;
#if ENABLE_ROTATE_INPUT
int16_t tmpRotateLen_;
#endif
};
} // namespace OHOS
#endif // GRAPHIC_LITE_UI_SCROLL_VIEW_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册