【发布时间】:2014-10-15 22:51:22
【问题描述】:
我有一个应用程序将照片列表加载到数组中,然后一张一张地显示这些照片。它应该被设计为将图像隐藏在右侧的窗口之外。然后图像应该从右向左滑入,直到它碰到左窗口边框。但是,在加载下一张图片时,如果图片需要一段时间才能加载旧图片,则会滑入。一旦新图片加载完毕,动画完成后会替换旧图片。
<body>
<img id="bg" class="clicky" alt=""></img>
more html...
</body>
function nextImage(){ // Load the next image and slide in from the right
raterReset(); // Function to reset keyboard hotkeys
loadImage(); // VBScript function to read the next image and make the filename
$("#bg").finish();
updateContainer(); // Function that obtains the window h/w and aspect ratio of image
showStatus("Next Image Loaded: " + intPhotoCount + " of " + intFileCount);
$("#bg").animate({left: "+="+winW}, 0,function(){
$("#bg").attr("src",objOriginFile);
$("#bg").animate({left: "-="+winW}, 1500);
});
}
我尝试过使用:
$("#bg").attr("src",objOriginFile).load(function(){
$("#bg").animate({left: "-="+winW}, 1500);
});
第一张图片效果很好,但随后第二张图片像预期的那样滑入并继续运行第二次幻灯片动画,它消失在窗口的左侧。在第三张图像上,图像已经太靠右了,超出了窗外。
这里是实际 HTA 的链接。这必须在带有 IE 8+ 的 windows box 上运行。
https://dl.dropboxusercontent.com/u/52558409/Photorater/Photorater.zip
注意:我知道我的代码不是最好的,我可能做了很多不应该做的事情。请温柔:)
【问题讨论】:
标签: javascript jquery html autoresize aspect-ratio