使用 jQuery bgImageTransition 创建连续的淡入淡出

发布于 2024-12-09 00:59:10 字数 1017 浏览 0 评论 0原文

使用 http://plugins.jquery.com/project/bgImageTransition 玩得很开心使用 div 背景 url 创建交叉淡入淡出图像的幻灯片。我使用背景图像的原因是整个幻灯片需要圆角和插图阴影。问题是该插件似乎会淡入新图像,然后淡出原来的图像。我希望每个图像都是新的,而不是 A、B、A、D、A、X、A、E 等。

我制作了一个 JSFiddle: http://jsfiddle.net/dJgge/2/ 并复制了下面的相关代码:

var currImage = '007.jpg';
setInterval( function(){
    do{
        var randImage = bgImages[Math.ceil(Math.random()*(bgImages.length-1))];
    }while( randImage == currImage )
    currImage = randImage;
    jQuery('#thumbshow').BgImageTransition( 'path/'+currImage );
}, 2000)

这基本上在 #thumbshow 之上创建了 #thumbshow2,然后将其删除。我想我只需要随机化 #thumbshow 的背景图像,而 #thumbshow2 位于顶部:

var randImage2 = bgImages[Math.ceil(Math.random()*(bgImages.length-1))];
jQuery('#thumbshow').css('background',"url(path/"+randImage2+")");

但无论我把它放在哪里,它都会产生闪烁的图像效果。我还需要确保秘密替换的背景图像与当前顶部的图像不匹配。建议?

Having a hell of a time using http://plugins.jquery.com/project/bgImageTransition to create a slideshow of crossfaded images using div background urls. The reason I'm using background images is that the entire slideshow needs rounded corners and inset shadows. The problem is that the plugin seems to fade in a new image then fade back out to the original. I want each image to be new, not A, B, A, D, A, X, A, E, etc.

I made a JSFiddle: http://jsfiddle.net/dJgge/2/ and also copied the relevant code below:

var currImage = '007.jpg';
setInterval( function(){
    do{
        var randImage = bgImages[Math.ceil(Math.random()*(bgImages.length-1))];
    }while( randImage == currImage )
    currImage = randImage;
    jQuery('#thumbshow').BgImageTransition( 'path/'+currImage );
}, 2000)

This basically creates #thumbshow2 on top of #thumbshow, then removes it. I figured I just need to randomize the background image of #thumbshow while #thumbshow2 is on top:

var randImage2 = bgImages[Math.ceil(Math.random()*(bgImages.length-1))];
jQuery('#thumbshow').css('background',"url(path/"+randImage2+")");

But wherever I put this, it creates a flashing image effect. And I also need to ensure the secretly replaced background image doesn't match the one currently on top. Suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昵称有卵用 2024-12-16 00:59:10

我能够使用“Cycle”插件让它工作,该插件对于过渡来说是坚如磐石的。看看这里的小提琴,看看这是否能让你更接近你需要的地方。它仍然使用背景图像,但在动态添加到父幻灯片元素的单独 div 上执行此操作。

http://jsfiddle.net/H7Q33/1/

Cycle 插件在这里....

http://jquery.malsup.com/cycle/

I was able to get it working using the "Cycle" plugin which is rock solid for transitions. Check out the fiddle here and see if this gets you closer to where you need to be. It's still using background images, but doing so on separate div's which are dynamically added to the parent slide show element.

http://jsfiddle.net/H7Q33/1/

Cycle plugin is here....

http://jquery.malsup.com/cycle/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文