Bootstrap轮播幻灯片问题上的火灾事件 [英] Fire event on Bootstrap carousel slide issue

查看:69
本文介绍了Bootstrap轮播幻灯片问题上的火灾事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用此代码在轮播幻灯片上触发事件,但是由于某些原因它无法正常工作.有什么建议吗?

I try to use this code to fire on an event upon carousel slide, but it fails to work for some reason. Any suggestions?

var $carousel = $('#carousel-showcase');
$carousel.carousel();

$carousel.bind('slide', function(e) {

  setTimeout( function(){
    var left = $carousel.find('.item.active.left');
    var right = $carousel.find('.item.active.right');
    if(left.length > 0) {
    $("#wrap").animate({
        backgroundPositionX: '+=50%'
    },0);
    }
    else if(right.length > 0) {
    $("#wrap").animate({
        backgroundPositionX: '-=50%'
    },0);
    }
  }, 500);
});

推荐答案

引导程序3将'slide'事件更改为'slide.bs.carousel'.对此进行更改,它应该可以工作(假设这是您唯一的问题):

Bootstrap 3 changed the 'slide' event to 'slide.bs.carousel'. Change to this and it should work (assuming that is your only issue):

$carousel.bind('slide.bs.carousel', function (e) {
    console.log('slide event!');
});

请参阅此问题.

这篇关于Bootstrap轮播幻灯片问题上的火灾事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆