我希望在这个脚本上使用回调 - 第三个回调onSlideChangeStart(swiper)http://idangero.us/swiper/api/#.V9CMp5grJlY但是我从未使用过回调而且无法从哪里开始。
所以基本上我想在页面的其他地方添加/删除一个类,其中另一个元素作为类等于swiper幻灯片上的datatag。关于如何开始这个的任何提示?
我目前工作的js是:
//swiper script for featured director spots
//initialize swiper when document ready
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'horizontal',
loop: true,
keyboardControl: true,
mousewheelControl: true,
pagination: '.swiper-pagination',
/*paginationElement: 'span',*/
paginationClickable: true,
paginationBulletRender: function (index, className) {
return '<a class=" ' + className + ' "><i class="fa fa-dot-circle-o active"></i><i class="fa fa-circle non-active"></i></a>';
}
})
我知道如何添加/删除/切换类但不知道如何使用回调来触发它。请指教。
所以基本上我需要知道如何添加回调 - 可能在回调中有一点在这里添加更多代码或类似。
谢谢。
答案 0 :(得分:1)
应该是这样的:
mySwiper.on('onSlideChangeStart', function () {
// do your stuff here
});
// do a console log on mySwiper to see what exactly is being passed
console.log(mySwiper);