First you need to disable the tempo when loading the page using:
"startOnPageLoad" : false
Also citing from the documentation for the pace:
The elements displayed on the screen allow us to decide that the page has been displayed.
So, we can say that loading the "image" should successfully complete the pace:
"elements": { "selectors": ["#image"] // assign id="image" to img }
Download the pace with these parameters specified in the script tag:
data-pace-options='{ "elements": { "selectors": ["#image"] }, "startOnPageLoad": false }'
Now just call Pace.restart () every time you click the "Download Image" link.
No need to call Pace.stop (). (it automatically detects that #image has finished loading)
Updated plunk
Bolaka
source share