chjtx / JRoll

Smooth scrolling for the mobile web
http://www.chjtx.com/JRoll/
MIT License
460 stars 92 forks source link

嵌套使用问题 #44

Closed sea35 closed 6 years ago

sea35 commented 6 years ago

嵌套使用,父元素为上下滑动,子元素为左右滑动,这时有个需求是焦点在子元素时向上滑或向下滑,希望是触发父元素的上下滑动,但是动不了,因为这时的焦点在子元素上,这个需求需要如何处理

chjtx commented 6 years ago

用call方法就可以

// outer 外层
// inter 内层
inter.on('scrollStart', () => {
  this.tempX = this.x // 找个变量记录一下
})
inter.on('scroll', e => {
  if (this.tempX === this.x) { // x的值没改变,表明是上下滑动
    this.call(outer, e)
 }
})