提交 0b2e8333 编写于 作者: Y YueBiang

fix rotate event bug for UIScrollView

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