【问题标题】:Swiper, how to get translateX real-time?Swiper,如何实时获取 translateX?
【发布时间】:2018-01-22 06:45:33
【问题描述】:

我想实时获取swiper-wrapper 的 translateX。我会使用实时的translateX 做一些工作。

swiper.on('sliderMove', function onSliderMove() {
  console.log(this.getTranslate(), this.translate); //-64 -64, or maybe other value, but not -320
});

我听sliderMove事件,但结果不正确。

我检查swiper-wrapper元素,样式是

transition-duration: 0ms; 
transform: translate3d(-320px, 0px, 0px);

我希望this.getTranslate() 的值应该是-320,而不是-64

【问题讨论】:

    标签: swiper


    【解决方案1】:

    收听setTranslate 事件将起作用。

    swiper.on('setTranslate', function onSliderMove() {
      console.log(this.translate);
    });
    

    【讨论】:

      猜你喜欢
      • 2014-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-15
      • 1970-01-01
      相关资源
      最近更新 更多