jQuery Preloading images for animation

前端 未结 1 1828
长发绾君心
长发绾君心 2020-12-21 11:52

I know there are heaps of jQuery preloading threads, and I\'ve read through most of them but still can\'t seem to find the solution to my problem.

I have a \"stop mo

相关标签:
1条回答
  • 2020-12-21 12:12

    The problem is this:

    When you assign a value to the src field of an Image object, it does just that: changes the src attribute. The browser still needs to load the image from wherever the src attribute points.

    You can define a handler for the 'load' event of an Image... so you're going to need to use something along those lines.

    One approach would be to define a list of images that need to be loaded. Each time an Image is loaded, set a flag in the array. Periodically, check the array and, once all the flags are set, indicating that all images are loaded, you can fade in your div.

    0 讨论(0)
提交回复
热议问题