Implementing background loading properly and efficiently

The following code is a summary of what I'm trying to do, which is to develop a interface that allows the user to scroll left and right through images. Images start off the screen and then to the centre, and it also pushes the previous image back off the screen. I would love some advice on the code I have or suggestions on how to do it better. Obviously, if the user rapidly clicks the arrows it will undoubtedly break the script, so I will need help here. Maybe prevent the arrows from being clicked when in a "load" state? I should also mention that backgroundLoad preloads the next and previous image. And when I say "off screen" it will animate to the centre. I'm not looking for a image gallery/lightbox solution. This question is more about the preloading process. var imgArray=[]; var b = 0; function loadImage(ini){ b = ini; //preload image var num_loaded = 0; imgArray[ini] = new Array();; for(var i=0;i

以上就是Implementing background loading properly and efficiently的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准