Skip to content

Commit

Permalink
fix: 🐞 load可能为空
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocyss committed Apr 10, 2024
1 parent 2ee169f commit da39d83
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,22 @@ export function delay(ms: number) {
cancelAnimationFrame(delayLoadId);
delayLoadId = undefined;
}
animate({
duration: ms,
callId(id) {
delayLoadId = id;
},
timing(timeFraction) {
return timeFraction;
},
draw(progress) {
load.style.width = progress * 100 + "%";
},
end() {
load.style.width = "0%";
},
});
if (load)
animate({
duration: ms,
callId(id) {
delayLoadId = id;
},
timing(timeFraction) {
return timeFraction;
},
draw(progress) {
if (load) load.style.width = progress * 100 + "%";
},
end() {
if (load) load.style.width = "0%";
},
});
return new Promise((resolve) => setTimeout(resolve, ms));
}

Expand Down

0 comments on commit da39d83

Please sign in to comment.