diff --git a/frameworks/components/ui_scroll_view.cpp b/frameworks/components/ui_scroll_view.cpp index bb05fe555fdd7233e24fa36e0cf7f750a3775a4f..be954ab0f859cd1ca327beb0d3961cf5495d29c1 100755 --- a/frameworks/components/ui_scroll_view.cpp +++ b/frameworks/components/ui_scroll_view.cpp @@ -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(event.GetRotate() * rotateFactor_); int16_t midPointX = static_cast(GetWidth() / 2); // 2 : Get the middle point X coord of the view int16_t midPointY = static_cast(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(midPointY + tmpRotateLen)}) - : (current = Point {static_cast(midPointX + tmpRotateLen), midPointY}); + yScrollable_ ? (current = Point {midPointX, static_cast(midPointY + tmpRotateLen_)}) + : (current = Point {static_cast(midPointX + tmpRotateLen_), midPointY}); DragThrowAnimator(current, last); + tmpRotateLen_ = 0; + } else { + tmpRotateLen_ = static_cast(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 diff --git a/interfaces/kits/components/ui_scroll_view.h b/interfaces/kits/components/ui_scroll_view.h index 6785d6dc4c209a7c361155b4b751e2bfed3c4090..37fc6b1fa51515547de4c2a35ef9b9f951eb2a64 100755 --- a/interfaces/kits/components/ui_scroll_view.h +++ b/interfaces/kits/components/ui_scroll_view.h @@ -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