jCarousel Lite 具有缩放和淡入淡出效果
我被困在这个问题上,所以希望有人能提供帮助。
我有一个正在使用 jCarousel Lite 的网站,并且我在图像上添加了放大效果和淡入淡出效果。这是初始化 jCarousel lite 的代码。
window.onload = function() {
jQuery("#midbody").jCarouselLite({
auto: 3000,
speed: 0,
circular: true,
beforeStart: function(a) {
width = jQuery(a).find("img").width() * zoom;
height = jQuery(a).find("img").height() * zoom;
jQuery(a).stop(false,true).find("img").animate({"width":width, "height":height, "top":move, "left":move}, 2000, "linear", function(){ jQuery(this).removeAttr("style");});
jQuery(a).parent().fadeTo(1000, 0);
},
afterEnd: function(a) {
jQuery(a).parent().fadeTo(1000, 1);
},
visible: 1
});
}
这是我一直在努力实现这一目标的网站。
如果您观看轮播,则第一次运行一切正常,但之后是我未排序列表中的第一个图像不再缩放。列表中的其余图像将继续缩放,这只是第一个出现此问题的图像。我认为可能是 jCarouselLite 出了问题,但我找不到任何东西。谢谢。
/* 编辑 */
StackOverflow 不允许我回答我自己的问题,因为我刚刚创建了这个帐户。所以我想我应该编辑原始内容并将其添加进去。如果这不被认为是犹太洁食,我很抱歉。
好的,我已经想出了一个解决方案。我必须在轮播中的每个图像上触发动画,而不是在可见的单个图像上触发动画。然后我在完成后使用 jcarousellite 的回调来停止所有图像上的所有动画,并重置样式属性。这是修改后的代码。
window.onload = function() {
jQuery("#midbody").jCarouselLite({
auto: 5000,
speed: 0,
circular: true,
beforeStart: function(a) {
width = jQuery(a).find("img").width() * zoom;
height = jQuery(a).find("img").height() * zoom;
jQuery(a).parent().find("img").animate({"width":width, "height":height, "top":move, "left":move}, 2000, "linear");
jQuery(a).parent().fadeTo(1000, 0);
},
afterEnd: function(a) {
jQuery(a).parent().find("img").stop(true,true).removeAttr("style");
jQuery(a).parent().fadeTo(1000, 1);
},
visible: 1
});
如果
有人知道更好的解决方案,或者如何让它在单个图像上工作,请告诉我。谢谢。
I'm stuck on this one, so hopefully someone can help.
I have a website I am using jCarousel Lite on, and I have added a zoom in effect as well as a fade effect on the images. Here is the code for initializing jCarousel lite.
window.onload = function() {
jQuery("#midbody").jCarouselLite({
auto: 3000,
speed: 0,
circular: true,
beforeStart: function(a) {
width = jQuery(a).find("img").width() * zoom;
height = jQuery(a).find("img").height() * zoom;
jQuery(a).stop(false,true).find("img").animate({"width":width, "height":height, "top":move, "left":move}, 2000, "linear", function(){ jQuery(this).removeAttr("style");});
jQuery(a).parent().fadeTo(1000, 0);
},
afterEnd: function(a) {
jQuery(a).parent().fadeTo(1000, 1);
},
visible: 1
});
}
Here is the website I have been trying to get this working on.
If you watch the carousel everything runs fine the first go around, but after that the first image in my unsorted list no longer zooms. The rest of the images in the list will continue to zoom, it's just the first one that is having this problem. I think it might be jCarouselLite that is at fault, but I couldn't find anything. Thanks.
/* EDIT */
StackOverflow wouldn't allow me to answer my own question since I just created this account. So I figured I would just edit the original and add it in. Sorry if this isn't considered kosher.
Ok, I have come up with a solution. Instead of firing an animation on the individual image that is visible, I had to fire the animation on each image in the carousel. Then I used the callback of jcarousellite for after completing to stop all animations on all the images, and reset the style attribute. Here is the revised code.
window.onload = function() {
jQuery("#midbody").jCarouselLite({
auto: 5000,
speed: 0,
circular: true,
beforeStart: function(a) {
width = jQuery(a).find("img").width() * zoom;
height = jQuery(a).find("img").height() * zoom;
jQuery(a).parent().find("img").animate({"width":width, "height":height, "top":move, "left":move}, 2000, "linear");
jQuery(a).parent().fadeTo(1000, 0);
},
afterEnd: function(a) {
jQuery(a).parent().find("img").stop(true,true).removeAttr("style");
jQuery(a).parent().fadeTo(1000, 1);
},
visible: 1
});
}
If someone knows of a better solution, or how to get it work on the individual images, please let me know. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论