Skip to content
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

Merged
merged 3 commits into from Feb 25, 2019
Merged

[New Feature] need wheel's disabled option[#712] #716

merged 3 commits into from Feb 25, 2019

Conversation

hezhongfeng
Copy link
Contributor

[New Feature] need wheel's disabled option[#712]

@hezhongfeng
Copy link
Contributor Author

hezhongfeng commented Dec 6, 2018

补充动图,手机录视频转gif太大了

BScroll.prototype._checkWheelhasValidIndex = function () {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].className.indexOf('disabled') === -1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里的 disabled 耦合严重,这里可以取一个配置项吧,参考下 wheels 配置的做法

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里取的就是配置项,这里的items是元素,只能凭借其class进行判断


BScroll.prototype._getWheelValidIndex = function (y) {
let tempIndex = Math.round(-y / this.itemHeight)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个函数的功能只是为了获取距离滚动方向相反最近的非 disabled 的 item 的索引吧,里面很多变量是多余的,当前对象上有属性可以判断滚动方向,逻辑写的太复杂了

@hezhongfeng
Copy link
Contributor Author

@theniceangel
我下班以后再看看,谢谢提意见

@theniceangel
Copy link
Collaborator

你给出的 gif 图貌似也有bug,从巫妖怎么到撼地神牛了,按道理如果你下滑,应该是向上找第一个非 disabled 的 item吧

@hezhongfeng
Copy link
Contributor Author

这里逻辑好像的确有问题,我当时考虑的是松手的时候就近找一个disable item

@hezhongfeng
Copy link
Contributor Author

@ustbhuangyi
黄老师能提提意见吗?准备继续修改

@hezhongfeng hezhongfeng closed this Dec 6, 2018
@hezhongfeng
Copy link
Contributor Author

@dolymood
gif里面的由巫医转到旱地神牛的时候,你看看是就近找一个非disabled的(目前的实现),还是沿着移动方向找一个惯性的?这个月加班较多,这几天一定要搞好,还等着在cube-ui里面用呢~

@dolymood dolymood reopened this Jan 10, 2019
@dolymood
Copy link
Collaborator

@hezhongfeng 参考 iOS 原生的 disabled 的行为就可以了

2、优化_getWheelValidIndex函数
@hezhongfeng
Copy link
Contributor Author

hezhongfeng commented Feb 16, 2019

gj
@dolymood 大佬

@theniceangel
Copy link
Collaborator

Thanks

@theniceangel theniceangel merged commit 27e227e into ustbhuangyi:dev Feb 25, 2019
@hezhongfeng
Copy link
Contributor Author

@theniceangel @dolymood 谢谢你们开源才好,等着合并到cube-ui的picker

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.

None yet

3 participants