เอฟเฟกต์ Light Speed Out
องค์ประกอบบินออกไปขวามุมพร้อมเงาเอียง (skew) และจางหาย เร็วมาก คล้ายแสงสว่าง ใช้ duration สั้น (0.25s)
โค้ดตัวอย่างสมบูรณ์
<html>
<head>
<style>
.animated {
background-image: url(/css/images/logo.png);
background-repeat: no-repeat;
background-position: left top;
padding-top: 95px;
margin-bottom: 60px;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes lightSpeedOut {
0% { -webkit-transform: translateX(0%) skewX(0deg); opacity: 1; }
100% { -webkit-transform: translateX(100%) skewX(-30deg); opacity: 0; }
}
@keyframes lightSpeedOut {
0% { transform: translateX(0%) skewX(0deg); opacity: 1; }
100% { transform: translateX(100%) skewX(-30deg); opacity: 0; }
}
.lightSpeedOut {
-webkit-animation-name: lightSpeedOut;
animation-name: lightSpeedOut;
-webkit-animation-timing-function: ease-in;
animation-timing-function: ease-in;
}
.animated.lightSpeedOut {
-webkit-animation-duration: 0.25s;
animation-duration: 0.25s;
}
</style>
</head>
<body>
<div id="animated-example" class="animated lightSpeedOut"></div>
<button onclick="myFunction()">Reload page</button>
<script>
function myFunction() { location.reload(); }
</script>
</body>
</html>
การวิเคราะห์ Keyframes
| ขั้นตอน | Transform | Opacity | พฤติกรรม |
|---|---|---|---|
| 0% | translateX(0%) skewX(0°) | 1 | เริ่มต้นปกติ |
| 100% | translateX(100%) skewX(-30°) | 0 | บินขวา + ก้มเอียง + จางหาย |
คุณสมบัติพิเศษ
- skewX(-30deg): สร้างเอฟเฟกต์ความเร็ว (motion blur feel)
- translateX(100%): บินออกหน้าจอแบบ relative
- ease-in: เริ่มช้า เร็วขึ้นทีหลัง (เหมือนเร่งความเร็ว)
- duration: 0.25s: เร็วมาก สร้างความรู้สึก "แสง"
คู่คู่กับ Light Speed In
ดูบทความต่อไป: Light Speed In (บินเข้ามา)