如何将自定义效果添加到Swiper滑块JavaScript库?

mil*_*dfm 3 javascript swiper

我想为Swiper滑块JavaScript库添加一个新的自定义效果.

默认组队,探索影响是slide,fade,cube,coverflowflip 但我想,以添加所有活动我的自定义效果.我怎样才能做到这一点?

Dac*_*ein 5

  1. 转到s.effects对象(效果部分)swiper.js并添加自己的效果属性,如下所示:

    myEffect: {
       setTranslate: function() {
           // your actual animation code goes here
       },
       setTransition: function( duration ) {
           // duration is between 0 and max speed (300 is default)
           // but you can change it in the config object below
           // is called when your swiping starts and ends
       }
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 要使用新效果,请执行以下操作:

    var mySwiper = new Swiper( '.swiper-container', {
           // other options …
           // and add this
           effect: “myEffect”
       }
    );
    
    Run Code Online (Sandbox Code Playgroud)

有关详细信息,请查看此处:https: //github.com/nolimits4web/Swiper/issues/1497

  • 它已经过时了 (2认同)