Skip to content

Add began and ended event to CCScrollview#1978

Merged
jareguo merged 4 commits intococos:masterfrom
feijing566:master
Sep 14, 2017
Merged

Add began and ended event to CCScrollview#1978
jareguo merged 4 commits intococos:masterfrom
feijing566:master

Conversation

@feijing566
Copy link
Copy Markdown
Contributor

sync from cocos2d/cocos2d-x#18054

@cocos-creator/engine-admins

@jareguo jareguo requested a review from knoxHuang September 13, 2017 07:38
Comment thread cocos2d/core/components/CCScrollView.js Outdated
/**
* !#en Query whether the user is currently dragging the ScrollView to scroll it
* !#zh 用户是否在拖拽当前滚动视图
* @method getContentPosition
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@method getContentPosition -> @method isScrolling

@knoxHuang
Copy link
Copy Markdown
Contributor

knoxHuang commented Sep 13, 2017

其他的我没啥问题了,你们在看看 @jare @pandamicro

Comment thread cocos2d/core/components/CCScrollView.js Outdated
'bounce-right' : EventType.BOUNCE_RIGHT,
'bounce-top' : EventType.BOUNCE_TOP,
'scroll-ended' : EventType.AUTOSCROLL_ENDED,
'auto-scroll-ended' : EventType.AUTOSCROLL_ENDED,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是否会导致 API 不兼容?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

除非用户用的是字符串 ‘scroll-ended’

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用户不会用到的,因为事件传递出来的是EventType.AUTOSCROLL_ENDED,是数字

Comment thread cocos2d/core/components/CCScrollView.js Outdated
'scroll-ended-with-threshold' : EventType.AUTOSCROLL_ENDED_WITH_THRESHOLD
'scroll-ended-with-threshold' : EventType.AUTOSCROLL_ENDED_WITH_THRESHOLD,
'scroll-began': EventType.SCROLLING_BEGAN,
'scroll-ended': EventType.SCROLLING_ENDED
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请把新增的事件补充到 event 注释区域中,在这个文件的最下面,你搜索 @event touch-up 就能看到

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加了

Comment thread cocos2d/core/components/CCScrollView.js Outdated
* !#zh 滚动视图滚动结束的时候发出的事件
* @property {Number} SCROLLING_ENDED
*/
SCROLLING_ENDED: 13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问什么时候需要区分 AUTOSCROLL_ENDED 和 SCROLLING_ENDED?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在没有触发惯性滚动的时候 就需要用SCROLLING_ENDED来通知滚动结束

Copy link
Copy Markdown
Contributor Author

@feijing566 feijing566 Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

滚动有2种结束方式,1种是立即结束1种就是需要惯性滚动一段距离后结束,这里的2个事件就是用来对应这2种操作

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那把这两个事件合并为一个 SCROLL_ENDED 就行了吧?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个就要看具体需求了。毕竟这里是2种状态,分成2个事件也是有他的价值的

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好像不对啊,判断是否要继续加载,应该是监听 scrolling 事件吧?因为只要有在滚动,不论是用户手指在拖拽还是自动滚动,都需要继续加载内容。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

就先合并这两个事件吧,统一叫 SCROLL_ENDED 就好,之后要是有遇到合理的需求再拆分。事件名称保持不变,还是叫做 scroll-ended,只不过之前是自动滚动停止时才触发,现在是不自动滚动的话,手动停止滚动也触发。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样会带来一个问题就是跟jsb的表现不一致,需要同步修改jsb的代码

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个只有 JS 层,C++ 那边不需要同步的

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合并了,麻烦看下

@jareguo jareguo merged commit a5af49a into cocos:master Sep 14, 2017
@jareguo
Copy link
Copy Markdown
Contributor

jareguo commented Sep 14, 2017

已合并,感谢帮忙!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants