2011-02-09 50 views
0

我有jQuery的周期精简版插件(http://jquery.malsup.com/cycle/)的问题jQuery的周期同步淡出

的图像似乎正在消失之前完全淡出,和我希望他们同时淡入/淡出。 http://hardingandwhitlock.com/v6/content/background

我有同步选项设置为1

$.fn.cycle.defaults = { 
    timeout:  2000, 
    speed:   200, 
    next:   null, 
    prev:   null, 
    before:  null, 
    after:   null, 
    height:  'auto', 
    sync:   1,  
    fit:   0,  
    pause:   0,  
    delay:   0,  
    slideExpr:  null 
}; 

任何帮助深表感谢!

回答

1

这听起来像你正试图从一个图像到另一个图像进行交叉淡入淡出。要做到这一点,你需要使用两个图像:

<img id="backImg" /> 
<img id="frontImg" /> 

设置#backImg要落后#frontImg像这样:

#backImg 
{ 
    position: absolute; 
} 

然后淡出前的图像......这会自动完成您的交叉淡入淡出效果,因为后面的图像已经加载在它后面。当淡出完成后,前方图像的源设置为背面图像的src,表现出来,接下来的图像预加载到背面图像:

function transitionImages(preloadImgUrl) 
{ 
    $("#frontImg").fadeOut("slow", function() 
    { 
     $("#frontImg").attr("src", $("#backImg").attr("src")).show(); 
     $("#backImg").attr("src", preloadImgUrl); 
    } 
} 

这一切都假定您的图片相同大小。如果不是的话,你会希望用css稍微详细一点,然后用淡入淡出的div来包装图像。

+0

我似乎已经知道了,但感谢您的建议 – Melody 2011-02-10 00:08:39

1

这结束了一些<br>所引起插入的<img>标签之间,以及剧本衰落的输入/输出,以及其间的所有图像

该网站是在Drupal正在做的,所以图像应插入到体内作为

<div id="slideshow"><img src="" /><img src="" />...</div> 

而不是在单独的行

<div id="slideshow"> 
    <img src="" /> 
    <img src="" /> 
</div> 

的Drupal似乎INSE rt <br>在每个单独的行之间。不知道其他CMS是否会做同样的工作