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

nested-scroll插件内外层bs的click在移动端存在bug #964

Closed
zellzh opened this issue Jan 21, 2020 · 3 comments
Closed

nested-scroll插件内外层bs的click在移动端存在bug #964

zellzh opened this issue Jan 21, 2020 · 3 comments
Assignees

Comments

@zellzh
Copy link

zellzh commented Jan 21, 2020

Version

2.0.0-beta.4

Reproduction link

https://didi.github.io/cube-ui/example/#/scroll/v-scrolls

Steps to reproduce

1.配置bs的click: true

2.监听内层bs内容的click事件

3.在移动端真机测试click产生bug

What is expected?

内外层bs配置click: true后, 在移动端能正常触发click事件

What is actually happening?

1.当内外层bs都配置click: true时: 外层能滚动阶段, click事件正常触发; 内层能滚动阶段, click事件无法触发

2.当只有innerScroll配置click: true时: 外层在滚动过程中, 一旦触碰到内层就会立即触发click事件; 而内层滚动和触发正常

3.当只有outerScroll配置click: true时: 效果同1

以上问题只出现在移动端, pc端正常触发

解决办法:

1.只给outerScroll配置click: true

2.在innerScroll变为enable时, 配置
innerScroll.options.click = true;

3.在innerScroll变为disable时, 配置innerScroll.options.click = false;


1.bs初始化配置:

initScroll () {

// outer

this.outerScroll = new BScroll(this.$refs.outerScroll, {

nestedScroll: true,
probeType: 3,
observeDOM: true,
click: true,
bounce: {
  bottom: false
}

})

// inner

this.innerScroll = new BScroll(this.$refs.innerScroll, {

nestedScroll: true,
probeType: 2,
observeDOM: true,
// click: true,
bounce: {
  top: false
}

})

}

2.解决bug的代码:

this.outerScroll.on('scroll', pos=> {

  if (...something) {

    ...

    this.outerScroll.disable()
    this.innerScroll.enable()
    this.innerScroll.options.click = true
  } else {
    this.innerScroll.options.click = false
  }

})

@theniceangel
Copy link
Collaborator

@zellzh 我试了一下,没啥问题啊,麻烦贴一下你的代码

@zellzh
Copy link
Author

zellzh commented Feb 13, 2020

@theniceangel https://github.com/zellzh/music_app/blob/home/src/views/Detail.vue
能在调用disable后只禁用touchmove, 而不禁用click吗? 可能会有这种需求, 比如禁用外层滚动的同时需要监听外层的click事件?

@theniceangel
Copy link
Collaborator

fixed at v2.1.0

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

No branches or pull requests

2 participants