-1

I always use a spinner from ajaxload.info first I show the spinner and then I hide it when the page completely loaded. But I was trying to create a spinner like youtube does without any luck.

How can I get the time in milliseconds that spent the image to load. In this scenario I should pass the value of millisecond to my animate jquery function.

This is my code:

$( "#some-image" ).animate({
    width: "100%"
}, 5000);//duration

$('#some-image').load(function() {
    $( "#spinner" ).hide();
});
napstercake
  • 1,815
  • 6
  • 32
  • 57
  • Questions concerning problems with code you've written must describe the specific problem — **and include valid code to reproduce it** — in the question itself. See [SSCCE.org](http://sscce.org) for guidance. On top of this, questions concerning [How to use jquery to create progress bar for loading an image?](http://stackoverflow.com/questions/3098489/how-to-use-jquery-to-create-progress-bar-for-loading-an-image?rq=1) are already littered across this site, and an answer to your question has surely already beeen written. – Ohgodwhy Sep 13 '13 at 00:05

1 Answers1

0

Tutorialzine posted an article recently explaining one technique to something similar using NProgress.

One way to achieve it (as mentioned in the article above) is to trigger a custom event when each image has loaded, and change the position of the progress bar until all images have loaded.

The way you are trying to achieve it would mean estimating the time to download each image, which isn't reliable.

N1ck
  • 2,001
  • 16
  • 23