0

这种紧急情况,求各位大神帮帮我……

我正在为幻灯片使用movingboxes插件(这是原始插件:http://css-tricks.com/moving-boxes/)我需要帮助设置回调函数添加到动画的末尾。我需要添加淡入淡出效果,当currentSlidecomplete滑动时,它应该开始淡入同一图像的另一个视图,例如,surrentSlidesrc 是images/dr1.jpg,我需要它淡入images/dr1b.jpg并返回到 images/dr1.jpg。循环遍历每个当前幻灯片

类似完成的东西:

function(e, slider, tar){

    //fading for each currentSlide goes here;//
  }
4

1 回答 1

0

像你描述的东西已经在文档中

请参阅此处的文档 [1],更具体地说,请参阅此处的文档 [2]。

编辑:在这里检查 jsfiddle,我使用了一个 jquery 插件http://jsfiddle.net/r6yWC/157/ 插件在这里http://jqueryfordesigners.com/image-cross-fade-transition/ 我还编辑了下面的代码部分。我在 img 标签中添加了“fade”类,如下所示:

<img class="fade" src="http://chriscoyier.github.com/MovingBoxes/demo/4.jpg" alt="picture" style="background: url(http://chriscoyier.github.com/MovingBoxes/demo/2.jpg);"/>

在第二个链接中,您将找到一个带有已完成回调的movingBoxes 示例。

(function ($) {
    $.fn.cross = function (options) {
        return this.each(function (i) { 
            // cache the copy of jQuery(this) - the start image
            var $$ = $(this);

            // get the target from the backgroundImage + regexp
            var target = $$.css('backgroundImage').replace(/^url|[\(\)'"]/g, '');

            // nice long chain: wrap img element in span
            $$.wrap('<span style="position: relative;"></span>')
                // change selector to parent - i.e. newly created span
                .parent()
                // prepend a new image inside the span
                .prepend('<img>')
                // change the selector to the newly created image
                .find(':first-child')
                // set the image to the target
                .attr('src', target);

            // the CSS styling of the start image needs to be handled
            // differently for different browsers
            if ($.browser.msie || $.browser.mozilla) {
                $$.css({
                    'position' : 'absolute', 
                    'left' : 0,
                    'background' : '',
                    'top' : this.offsetTop
                });
            } else if ($.browser.opera && $.browser.version < 9.5) {
                // Browser sniffing is bad - however opera < 9.5 has a render bug 
                // so this is required to get around it we can't apply the 'top' : 0 
                // separately because Mozilla strips the style set originally somehow...                    
                $$.css({
                    'position' : 'absolute', 
                    'left' : 0,
                    'background' : '',
                    'top' : "0"
                });
            } else { // Safari
                $$.css({
                    'position' : 'absolute', 
                    'left' : 0,
                    'background' : ''
                });
            }

            // similar effect as single image technique, except using .animate 
            // which will handle the fading up from the right opacity for us
            $$.hover(function () {
                $$.stop().animate({
                    opacity: 0
                }, 250);
            }, function () {
                $$.stop().animate({
                    opacity: 1
                }, 250);
            });
        });
    };

})(jQuery);

$('#slider').movingBoxes({
// **** Appearance ****
// start with this panel
 ...
 ...

//-----> here is your callback
// callback after animation completes
completed: function(e, slider, tar){
    var img = slider.$panels.eq(tar).find('img');
    img.cross();
img.stop().animate({opacity: 0}, 1250).delay(500).animate({opacity: 1}, 2550);
}

});​

[1] https://github.com/chriscoyier/MovingBoxes/wiki

[2] http://jsfiddle.net/Mottie/r6yWC/2/

于 2012-04-09T17:20:20.240 回答