简体   繁体   English

如何检查自举轮播是否已停止滑动?

[英]How to check if bootstrap carousel has stopped sliding?

I need to apply tooltip for the list that is feteched and shown using carousel. 我需要为使用轮播显示和显示的列表应用工具提示。 In that list of items whichever is wrapped with ellipses I need to show the tooltip for them. 在该项目列表中,无论哪个都用椭圆包裹,我都需要显示它们的工具提示。

But if I moveover mouse before sliding is completed then tooltip appears to be at the corner of page. 但是,如果我在滑动完成之前移过鼠标,则工具提示似乎在页面的一角。

This is my code to show tooltip on mouseover. 这是我的代码,用于在鼠标悬停时显示工具提示。

I checked using .slid event given in their website & also by checking if carousel-inner child is active or not but this also doesn't work and both these events fire before the sliding is complete. 我使用他们网站上提供的.slid事件进行了检查,还检查了轮播内的孩子是否处于活动状态,但这也不起作用,并且这两个事件在滑动完成之前都会触发。

$('.tooltipcheck').mouseover(function() {
     var $this = $(this);
     if (this.offsetWidth < this.scrollWidth)
        $(this).tooltip( {container: 'body'});
});

Bootstrap's carousel has a callback that can be hooked into after a slide has finished sliding (called 'slid'). Bootstrap的轮播有一个回调,可以在幻灯片完成滑动(称为“ slid”)后挂接到该回调中。 You could initiate your test in the slid callback, like so: 您可以在slid回调中启动测试,如下所示:

$('#myCarousel').on('slid', function() {
    $('.tooltipcheck').mouseover(function() {
         var $this = $(this);
         if (this.offsetWidth < this.scrollWidth)
         $(this).tooltip( {container: 'body'});
    });
});

That way you're not calling the test until after the slide has finished transitioning, and it'll refresh on every new slide transition. 这样,您直到幻灯片完成转换后才调用测试,并且它将在每次新的幻灯片转换时刷新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM