Hi,
I would like to know an opinion from the experts.
I have created 2 preloads.
The first one using onUpdate from GreenSock.
var obj = {prop: 1};
gsap.to(obj, {
duration: 1,
prop: 100,
//onUpdate fires each time the tween updates; we'll explain callbacks later.
onUpdate: function() {
gsap.to(".bar", {
width: obj.prop + "%" });
$(".percentage").html(parseInt(obj.prop) + "%");
console.log(parseInt(obj.prop)); //logs the value on each update.
},
onComplete: function(){
startTimeline();
}
});
I try to see inspect element and I get back the data :
15, 36, 67, 88, 94, 95, 96, 98, 98, 99, 99, 99, 100
The second one using JS PerformanceTiming.
I discovered this thanks to Ahsan K. Rathore. https://codepen.io/ahsanrathore/post/accurate-page-progress-bar
It seems to me that using this system the preload works much better.
the data that return to me are 1,2,3,4,5, etc..
I probably didn't understand well how onUpdate works, so I was wondering
if there is any way to get the same result using onUpdate, I would like to avoid to use the script of
Ahsan K. Rathore because I would prefer to use gsap directly.
Can you give me some indication of the error I am making or is the method wrong?
Thank you all.
Have a great Sunday.