高级JavaScript图像滑块
Advanced javascript image slider
我已经在谷歌上搜索了一段时间,意识到我需要帮助。
我正在为我的一个朋友开发PHP的东西,但他想要在他的网站上有一个非常难以编程的图像滑块(对我来说)。我是荷兰人,我要给你们看的例子是一个荷兰网站:http://www.iboma.com/index.asp。我正在尝试制作类似的动画,但是在javascript/jQuery中。
只是我需要淡入淡出图像和相应的链接,而不是显示示例木材。文本可能是额外的。不需要。
标准滑块不够好,所以我需要自定义代码。没有花哨的动画,交叉淡入淡出将是理想的。图像淡入后,我需要在覆盖背景图像时淡入淡出的图像+链接,同时保持示例网站上也显示的叠加徽标。
我想使用 JSON 数组或预加载在网站上提供来自 PHP 的图像滑块图像(可能搜索引擎更友好)。
var photos = [ { image: "http://localhost/foobar.png", logo: "http://localhost/foobar.png", link: "http://www.stackoverflow.com/" },
{ image: "http://localhost/foobar.png", logo: "http://localhost/foobar.png", link: "http://www.google.com/" },
{ image: "http://localhost/foobar.png", logo: "http://localhost/foobar.png", link: "http://www.yahoo.com/" }];
你们能帮我开发这样的动画吗?
开始:
我试图弄清楚如何有一个有效的无限循环来堆叠我必须触发的各种事件来动画化事物。
首先,我是否使用普通的javascript,或者我最好使用jQuery来加载和速度?
其次,对于无限循环,这种代码的良好实现是什么?
第三,如何一个接一个地触发各种事件,同时不中断动画的流程。
第四,在动画背景图像更改时,如何确保叠加徽标不会消失在动画后面?这是我的主要问题之一。使用淡入和淡出,徽标消失在我的图像后面。
建议?
我已经在谷歌上搜索了一段时间,我开始意识到我 真的需要一些帮助。
上面的行对我来说没有意义。
我在谷歌中输入了"图像滑块",这是第一个结果。
http://nivo.dev7studios.com/
这看起来很像你要问的。
有一个图像滑块的免费代码,带有链接,文本,几乎所有你需要的东西。
好的,据你所知,没有人会为你写它;)我可以推荐你幻灯片,这将简单地做到这一点 - http://jquery.malsup.com/cycle/
$('#slideshow').cycle({
fx: 'fade',
after: onAfter
});
function onAfter(curr, next, opts, fwd) {
//here you make animation with text and small image
};
它是如此简单,你所要做的就是取笑所有的动画。试试吧。无需为此编写自己的幻灯片代码。
终于得到了我需要的东西。
索夫卡,你在我路上帮助了我。谢谢。这就是我需要的。哦,我为此使用了轨道图像滑块。
以下代码对我有用:
(function($) {
$(document).ready(function() {
$('#featured').orbit({
animation: 'fade', // fade, horizontal-slide, vertical-slide, horizontal-push
animationSpeed: 500, // how fast animtions are
timer: true, // true or false to have the timer
advanceSpeed: 6000, // if timer is enabled, time between transitions
pauseOnHover: true, // if you hover pauses the slider
startClockOnMouseOut: true, // if clock should start on MouseOut
startClockOnMouseOutAfter: 0, // how long after MouseOut should the timer start again
directionalNav: false, // manual advancing directional navs
captions: false, // do you want captions?
captionAnimation: 'fade', // fade, slideOpen, none
captionAnimationSpeed: 800, // if so how quickly should they animate in
bullets: false, // true or false to activate the bullet navigation
bulletThumbs: false, // thumbnails for the bullets
bulletThumbLocation: '', // location from this file where thumbs will be
beforeSlideChange: function() {
$('#featured a, #featured span').fadeOut(400, function() {
$('#featured a, #featured span').remove();
});
$('#featured img').each(function(index) {
if ($('#featured img').eq(index).css("z-index") == 3) {
var className = $('#featured img').eq(index).attr("class");
$('#featured img')
.eq($('#featured img').index(this))
.after($('#featured-images .' + className)
.clone()
.css("z-index","4")
);
$('#featured a.' + className)
.css("top",$("#featured img." + className).height() - $("#featured img." + className).next("a").height() - 50)
.css("left",$("#featured img." + className).width() - $("#featured img." + className).next("a").width() - 50)
.fadeIn(1000, function() {
$('#featured a.' + className + ' img').fadeIn(1500);
$('#featured img')
.eq($('#featured img').index(this))
.after($('#featured-text .' + className)
.clone()
.css({"z-index":"4",
"top":"0px",
"display":"block",
"opacity":0,
"position":"absolute",
"left":$("#featured img." + className).width() - $("#featured img." + className).next("a").width() - 70 - $('#featured-text .' + className).width()})
);
$('#featured span.' + className).animate({
opacity: 1,
top: $("#featured img." + className).height() - $("#featured img." + className).next("a").height() - 25
}, 1000);
});
}
});
}
});
});
}(jQuery));
需要自己向代码库添加一些事件钩子,但这并不难。
.HTML:
<div id="featured">
<img src="http://localhost/foo/images/bar.png" class="image-1" width="924" height="317" alt="" />
<img src="http://img265.imageshack.us/img265/3355/62320763.jpg" class="image-2" width="924" height="317" alt="" />
<img src="http://img411.imageshack.us/img411/1237/75707805.jpg" class="image-3" width="924" height="317" alt="" />
</div>
<div id="featured-images">
<a href="" class="image-1" style="width:100px;height:50px;border:1px solid #FFF;"><img src="http://localhost/foo/images/foobar.png" width="100" height="50" alt="" style="display:none" /></a>
</div>
<div id="featured-text">
<span class="image-1" style="display:none;font-size:30px;color:#FFF;">Dit is een test</span>
</div>
- 更改下拉菜单上的图像javascript/jquery
- Chrome:刷新页面后未呈现的背景图像 + JavaScript 重定向
- 更改背景图像 - JavaScript
- 目标 css:背景图像 Javascript
- 如何显示数组中的图像?JavaScript
- 淡入淡出两个图像[JavaScript]
- 获取图像ID并更改图像JavaScript
- 显示多个图像-javascript
- 在不损失质量的情况下调整图像JavaScript/jQuery的大小
- 选择某个列表项时弹出的图像-javascript
- 将生成的随机数存储在变量中,然后将该变量作为文件名调用以显示图像.Javascript
- 更改悬停时的图像Javascript
- 在reactjs中呈现本地图像/javascript片段
- 键下时的反向图像 - Javascript
- 将所有图像替换为一个图像 Javascript
- 单击显示随机图像(Javascript)
- 移动图像 ..JavaScript 将变量声明为字符串
- 直方图均衡(图像Javascript初学者)
- 预加载库图像.JavaScript(没有JQuery)
- 用不同的图像/按钮替换图像 - javascript