未验证 提交 c78fee23 编写于 作者: O openharmony_ci 提交者: Gitee

!578 增加ScrollTop和ScrollBottom事件

Merge pull request !578 from 郝烁/master
......@@ -354,6 +354,31 @@ bool UIList::MoveOffset(int16_t x, int16_t y)
scrollListener_->OnScrollStart(onSelectedIndex_, onSelectedView_);
}
if (!isLoopList_ && scrollListener_) {
if (direction_ == VERTICAL) {
if (childrenHead_ && (childrenHead_->GetViewIndex() == startIndex_) &&
childrenHead_->GetRelativeRect().GetTop() >= 0 &&
childrenHead_->GetRelativeRect().GetTop() - y < 0) {
scrollListener_->OnScrollTop(childrenHead_->GetViewIndex(), childrenHead_);
}
if (childrenTail_ && (childrenTail_->GetViewIndex() == recycle_.GetAdapterItemCount()-1) &&
(childrenTail_->GetRelativeRect().GetBottom() <= GetContentRect().GetHeight() - 1) &&
(childrenTail_->GetRelativeRect().GetBottom() - y > GetContentRect().GetHeight() - 1)) {
scrollListener_->OnScrollBottom(childrenTail_->GetViewIndex(), childrenTail_);
}
} else {
if (childrenHead_ && (childrenHead_->GetViewIndex() == startIndex_) &&
childrenHead_->GetRelativeRect().GetLeft() >= 0 &&
childrenHead_->GetRelativeRect().GetLeft() - x < 0) {
scrollListener_->OnScrollTop(childrenHead_->GetViewIndex(), childrenHead_);
}
if (childrenTail_ && (childrenTail_->GetViewIndex() == recycle_.GetAdapterItemCount()-1) &&
(childrenTail_->GetRelativeRect().GetRight() <= GetContentRect().GetWidth() - 1) &&
(childrenTail_->GetRelativeRect().GetRight() - x > GetContentRect().GetWidth() - 1)) {
scrollListener_->OnScrollBottom(childrenTail_->GetViewIndex(), childrenTail_);
}
}
}
return true;
}
......
......@@ -93,6 +93,32 @@ public:
*/
virtual void OnScrollEnd(int16_t index, UIView* view) {}
/**
* @brief Called when move to the top of scroll.
*
* @param index Indicates the index of the child view being selected at the preset position. This parameter should
* be set to {@link NULL_SELECT_INDEX} if no child view is selected or no position is preset.
* @param view Indicates the child view being selected at the preset position. This parameter should be set to
* <b>NULL</b> if no child view is selected or no position is preset.
* @since 8
* @version 8
*
*/
virtual void OnScrollTop(int16_t index, UIView* view) {}
/**
* @brief Called when move to the bottom of scroll.
*
* @param index Indicates the index of the child view being selected at the preset position. This parameter should
* be set to {@link NULL_SELECT_INDEX} if no child view is selected or no position is preset.
* @param view Indicates the child view being selected at the preset position. This parameter should be set to
* <b>NULL</b> if no child view is selected or no position is preset.
* @since 8
* @version 8
*
*/
virtual void OnScrollBottom(int16_t index, UIView* view) {}
/**
* @brief Called when a new child view is selected at the preset position as this list scrolls. For details about
* how to set the position, see {@link SetSelectPosition}.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册