有没有办法在单独的线程上显示预加载动画,直到角度完全加载?我发现动画非常紧张而且不流畅。我查看了控制台,动画仅在加载脚本之间更新。如果脚本需要一段时间才能加载,则动画会冻结
例如,当以下脚本加载 main.js、styles.js,尤其是vendor.js 时,此动画会冻结,冻结时间为 1 到 2 秒。如下图所示
<!doctype html>
<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=edge">
<meta charset="utf-8">
<title>My Application</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<style>
app-root {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
color: #fff;
text-transform: uppercase;
font-family: -apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen-Sans,
Ubuntu,
Cantarell,
Helvetica,
sans-serif;
font-size: 2.5em;
text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
}
body {
transition: opacity 0 ease-in-out 1s;
background: darkgray;
margin: 0;
padding: 0;
}
@keyframes dots {
50% {
transform: translateY(-.4rem);
}
100% {
transform: translateY(0);
}
}
.d {
animation: dots 1.5s ease-out infinite;
}
.d-2 {
animation-delay: .9s;
}
.d-3 {
animation-delay: 1s;
}
</style>
Loading<span class="d">.</span><span class="d d-2">.</span><span class="d d-3">.</span>
</app-root>
</body>
</html>
拉风的咖菲猫
相关分类