Giter Site home page Giter Site logo

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

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

from vue-swipe.

Comments (3)

cloudfroster avatar cloudfroster commented on July 25, 2024

能详细描述下吗

from vue-swipe.

freedom-git avatar freedom-git commented on July 25, 2024

重现:
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>

from vue-swipe.

zhushuanglong avatar zhushuanglong commented on July 25, 2024

发现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
  });
}

from vue-swipe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.