【问题标题】:Changing fadeTo to a slide in Jquery在jQuery中将fadeTo更改为幻灯片
【发布时间】:2011-11-19 07:59:28
【问题描述】:

单击缩略图时,标准的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>

【问题讨论】:

    标签: jquery toggle slide fadeto


    【解决方案1】:

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

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

    这基本上意味着:

    • 订阅与“#thumbs ul.thumbs”选择器匹配的所有元素的点击事件
    • 当元素被点击时
    • 动画它向右移动 500 像素
    • 移除元素

    【讨论】:

      猜你喜欢
      • 2013-01-15
      • 2015-06-21
      • 1970-01-01
      • 2015-04-21
      • 1970-01-01
      • 1970-01-01
      • 2019-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多