代码之家  ›  专栏  ›  技术社区  ›  Phil

jQuery-jCarousel-FadeIn

  •  3
  • Phil  · 技术社区  · 17 年前

    我正在使用jCarousel插件( http://sorgalla.com/projects/jcarousel/ )而不是图像滑入(如“带自动滚动的旋转木马”演示)

    如果有人能帮上忙,谢谢。

    菲尔

    6 回复  |  直到 17 年前
        1
  •  6
  •   ogaltsev    12 年前

    试试这个:

    var jcarousel = $('#yourContainer');
    
        jcarousel.jcarousel({
            animation: {
                duration: 0 // make changing image immediately
            }
        });
    
        // make fadeIn effect
        jcarousel.on('jcarousel:animate', function (event, carousel) {
            $(carousel._element.context).find('li').hide().fadeIn(1000);
        });
    
        2
  •  6
  •   Nikit    6 年前

    即使jCarousel只知道滚动幻灯片,也可以模拟淡入淡出效果:

    $('#yourContainer').jcarousel({
        visible: 1,
        scroll: 1, 
        itemLoadCallback: {
            onBeforeAnimation: mycarousel_fadeOut,
            onAfterAnimation: mycarousel_fadeIn
        }
    });
    
    function mycarousel_fadeOut(carousel) {
        var JCcontainer = carousel.clip.context; 
        $(JCcontainer).fadeOut(); 
    }
    
    function mycarousel_fadeIn(carousel) {
        var JCcontainer = carousel.clip.context; 
        $(JCcontainer).fadeIn(); 
    }
    

    这样,您可以在滚动动画开始之前淡出容器,并在完成后淡入容器,而不会看到除淡入效果以外的任何其他效果。

        3
  •  2
  •   Jamie    14 年前

    将功能更改为此工作,类似于(您仍然可以看到滚动):

    function mycarousel_fadeOut(carousel) { 
       var JCcontainer = carousel.clip.context; 
       $(JCcontainer).fadeOut(); 
    } 
    
    function mycarousel_fadeIn(carousel) { 
       var JCcontainer = carousel.clip.context; 
       $(JCcontainer).fadeIn(); 
    } 
    
        4
  •  1
  •   stanleyhlng    14 年前
    var mycarousel_fadeOut = function(carousel, state) {
        if (state !== "init") {
            $(carousel.clip.context).find('img').fadeOut(800);
        }
    };
    
    var mycarousel_fadeIn = function(carousel, state) {
        if (state !== "init") {
            $(carousel.clip.context).find('img').fadeIn(800);
        }
    };
    
        5
  •  1
  •   Gappa    12 年前

       var carousel = $('.jcarousel').jcarousel({
          list        : '.items',
          items       : '.i',
          wrap        : 'both', // for good measure
          animation: {
              duration: 0 // swap slides immediately
          }
       }).jcarouselAutoscroll({
          interval: 1000 * 5,
          target: '+=1',
          autostart: true
       });
    
       // fade hack
       carousel.jcarousel('items').hide();
       carousel.jcarousel('first').show();
       carousel.on('jcarousel:visiblein', function(event, carousel) {
          $(event.target).fadeIn();
       });
       carousel.on('jcarousel:visibleout', function(event, carousel) {
          $(event.target).fadeOut();
          carousel._trigger('animateend'); // the event doesn't fire when items are positioned absolutely (so autoscroll wouldn't work), fire manually
       });
    

    一些css使其工作:

       .items {height: 450px;}
       .i     {position: absolute;}
    
        6
  •  0
  •   Andy Gaskell    17 年前

    on this page 查看循环使用文本。