滚动页面时重置Twiiter引导轮播 [英] Reset Twiiter bootstrap carousel when scrolls of page

查看:79
本文介绍了滚动页面时重置Twiiter引导轮播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道在不再可见的情况下是否可以重置twitter bootstrap轮播吗?

Does anyone know if there is a way to reset twitter bootstrap carousel when it is no longer visible?

我在页面顶部放了三张幻灯片,当用户向下滚动到页面的其余部分时,有没有办法将其滑回第一个?

I have it on the top of the page with three slides, is there a way to slide it back to the first one when the users scrolls down to the rest of the page?

预先感谢

推荐答案

您可能应该对代码进行一些优化,但这应该可以帮助您入门:

You should probably optimize the code a bit but this should get you started:

var getPageScroll = function(document_el, window_el) {
      var xScroll = 0, yScroll = 0;
      if (window_el.pageYOffset !== undefined) {
        yScroll = window_el.pageYOffset;
        xScroll = window_el.pageXOffset;
      } else if (document_el.documentElement !== undefined && document_el.documentElement.scrollTop) {
        yScroll = document_el.documentElement.scrollTop;
        xScroll = document_el.documentElement.scrollLeft;
      } else if (document_el.body !== undefined) {// all other Explorers
        yScroll = document_el.body.scrollTop;
        xScroll = document_el.body.scrollLeft;
      }
      return [xScroll,yScroll];
    };

    $(window).scroll(function(e) {
        var top = $('#carousel-example-generic').offset().top;
        if(top < getPageScroll(document,window)[1]) $('#carousel-example-generic').carousel(0);
    });

这篇关于滚动页面时重置Twiiter引导轮播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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