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

使用goto跳转两个以上页面之后,除了首尾页,其他页会出现swipe-item上绑定click事件无法触发的问题。 #59

Open
freedom-git opened this issue Oct 12, 2017 · 3 comments

Comments

@freedom-git
Copy link

出现问题之后左右滑动一下,问题就消失了。

@cloudfroster
Copy link
Contributor

能详细描述下吗

@freedom-git
Copy link
Author

重现:
step1: 创建一个新项目,用v-for的方式循环出4张swipe-item。
step2: 将auto设为0,将点击事件(@click.native)绑定到swipe-item上。
step3: 在显示第一张,也就是index=0的时候. 使用goto方法跳转到第三张,也就是index=2. 点击滑动部分,会发现绑定的点击事件无法触发。

目前的解决方法:
通过onchange事件记录index,然后将点击事件绑定到外层swipe的组件上。

环境:
chrome

代码:
<swipe ref="swipe" :auto="0" :showIndicators=false class="my-swipe" @change="change"> <swipe-item class="slide" v-for="(item, index) in data" :key="item.key" :style="{'background-image': 'url('+item.pic+')'}" @click.native="swipeItemClick(item,index)"></swipe-item> </swipe>

@zhushuanglong
Copy link

发现goto的一个bug , 然后修复了这个问题;希望对你有所帮助,修改方式如下:

swipe.vue

// line 305
if (prevPage && options.goTowards === 'prev') {
  this.translate(currentPage, pageWidth, speed, callback);
  this.translate(prevPage, 0, speed);
} else if (nextPage && options.goTowards === 'next') {
  this.translate(currentPage, -pageWidth, speed, callback);
  this.translate(nextPage, 0, speed);
}
// line 344
if (newIndex < this.index) {
  this.doAnimate('goto', {
    newIndex,
    prevPage: this.pages[newIndex],
    goTowards: 'prev' // towards prev
  });
} else {
  this.doAnimate('goto', {
    newIndex,
    nextPage: this.pages[newIndex],
    goTowards: 'next' // towards next
  });
}

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

3 participants