将fadeTo更改为Jquery中的幻灯片

时间:2011-11-18 23:19:45

标签: jquery toggle slide fadeto

单击缩略图时,标准galeriffic图库在图像之间淡入淡出。如何更改图库,以便图像从页面向右滑动,显示下面的下一个图像?感谢

<script>
    jQuery(document).ready(function($) {
        // We only want these styles applied when javascript is enabled
        $('div.navigation').css({'width' : '300px', 'float' : 'left'});
        $('div.content').css('display', 'block');

        // Initially set opacity on thumbs and add
        // additional styling for hover effect on thumbs
        var onMouseOutOpacity = 1.0;
        $('#thumbs ul.thumbs li').opacityrollover({
            mouseOutOpacity:   onMouseOutOpacity,
            mouseOverOpacity:  1.0,
            fadeSpeed:         'fast',
            exemptionSelector: '.selected'
        });

        // Initialize Advanced Galleriffic Gallery
        var gallery = $('#thumbs').galleriffic({
            delay:                     2500,
            numThumbs:                 100,
            preloadAhead:              100,
            enableTopPager:            true,
            enableBottomPager:         true,
            maxPagesToShow:            100,
            imageContainerSel:         '#slideshow',
            controlsContainerSel:      '#controls',
            captionContainerSel:       '#caption',
            loadingContainerSel:       '#loading',
            renderSSControls:          false,
            renderNavControls:         false,
            playLinkText:              '',
            pauseLinkText:             '',
            prevLinkText:              '',
            nextLinkText:              '',
            nextPageLinkText:          '',
            prevPageLinkText:          '',
            enableHistory:             false,
            autoStart:                 false,
            syncTransitions:           true,
            defaultTransitionDuration: 900,
            onSlideChange:             function(prevIndex, nextIndex) {
                // 'this' refers to the gallery, which is an extension of $('#thumbs')
                this.find('ul.thumbs').children()
                    .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
                    .eq(nextIndex).fadeTo('fast', 1.0);
            },
            onPageTransitionOut:       function(callback) {
                this.fadeTo('fast', 0.0, callback);
            },
            onPageTransitionIn:        function() {
                this.fadeTo('fast', 1.0);
            }
        });
    });
</script>

1 个答案:

答案 0 :(得分:1)

您可以像这样使用jQuery clickanimateremove函数:

$('#thumbs ul.thumbs').click(function() {
  var self = $(this);    
  self.animate({left: '+=500'}, 1000, 'linear', function() {
    self.remove();
  });
});

这基本上意味着:

  • 订阅与'#thumbs ul.thumbs'选择器
  • 匹配的所有元素的点击事件
  • 点击元素时
  • 动画显示向右移动500像素
  • 删除元素