New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New Feature] need wheel's disabled option[#712] #716
Conversation
BScroll.prototype._checkWheelhasValidIndex = function () { | ||
for (let i = 0; i < this.items.length; i++) { | ||
if (this.items[i].className.indexOf('disabled') === -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 disabled 耦合严重,这里可以取一个配置项吧,参考下 wheels 配置的做法
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里取的就是配置项,这里的items
是元素,只能凭借其class进行判断
src/scroll/wheel.js
Outdated
|
||
BScroll.prototype._getWheelValidIndex = function (y) { | ||
let tempIndex = Math.round(-y / this.itemHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数的功能只是为了获取距离滚动方向相反最近的非 disabled 的 item 的索引吧,里面很多变量是多余的,当前对象上有属性可以判断滚动方向,逻辑写的太复杂了
@theniceangel |
你给出的 gif 图貌似也有bug,从巫妖怎么到撼地神牛了,按道理如果你下滑,应该是向上找第一个非 disabled 的 item吧 |
这里逻辑好像的确有问题,我当时考虑的是松手的时候就近找一个 |
@ustbhuangyi |
@dolymood |
@hezhongfeng 参考 iOS 原生的 disabled 的行为就可以了 |
2、优化_getWheelValidIndex函数
|
Thanks |
@theniceangel @dolymood 谢谢你们开源才好,等着合并到cube-ui的picker |
[New Feature] need wheel's disabled option[#712]