The example in this article describes the method of javascript image preloading. Share it with everyone for your reference. The details are as follows:
Lightbox effects use preloading to center-display images. They need to wait until they are fully loaded before they can be displayed, resulting in a poor experience (such as the full-screen effect of filick albums). JavaScript cannot obtain img file header data. Is this really the case? This article uses a clever method to let javascript obtain it.
This is an example of how most people use preloading to get the image size:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
JavaScript code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
Call example:
1 2 3 |
|
I hope this article will be helpful to everyone’s JavaScript programming design.