I also had this problem. The reason you need to call the center twice is because the pop-up container is actually removed from the DOM when the pop-up is βhiddenβ. This is problematic because your popup should now βshowβ the contents of the popup before you can verify that the image is loaded.
The problem with the recommended implementation is that the first call to the center () function will fail if the image is not cached. A second call to the center will fix it. In the browser, this causes the pop-up dialog box to shift (which looks pretty bad).
I would recommend the following: 1. Place the pending counter on the same display and show it first. 2. One called loadHandler, displays the image, hides the counter and regenerator.
source share