เอฟเฟกต์ Rotate In
องค์ประกอบหมุนเข้ามาจาก -200° (หมุนหลายรอบ) ไปสู่ 0° พร้อมจางเข้ามา จุดหมุนอยู่กึ่งกลาง (center center)
โค้ดตัวอย่างสมบูรณ์
<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: 10s;
animation-duration: 10s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes rotateIn {
0% { -webkit-transform-origin: center center; -webkit-transform: rotate(-200deg); opacity: 0; }
100% { -webkit-transform-origin: center center; -webkit-transform: rotate(0); opacity: 1; }
}
@keyframes rotateIn {
0% { transform-origin: center center; transform: rotate(-200deg); opacity: 0; }
100% { transform-origin: center center; transform: rotate(0); opacity: 1; }
}
.rotateIn {
-webkit-animation-name: rotateIn;
animation-name: rotateIn;
}
</style>
</head>
<body>
<div id="animated-example" class="animated rotateIn"></div>
<button onclick="myFunction()">Reload page</button>
<script>
function myFunction() { location.reload(); }
</script>
</body>
</html>
การวิเคราะห์
| ขั้นตอน | Rotate | Opacity | พฤติกรรม |
| 0% | -200° | 0 | หมุนวนรอบๆ จางหาย |
| 100% | 0° | 1 | หยุดตรงหน้า มองเห็นชัด |
ความแตกต่าง Rotate In แบบต่างๆ
| เอฟเฟกต์ | Transform Origin | Rotate เริ่มต้น |
| rotateIn | center center | -200deg (หลายรอบ) |
| rotateInDownLeft | left bottom | -90deg |
| rotateInDownRight | right bottom | 90deg |
| rotateInUpLeft | left top | 90deg |
| rotateInUpRight | right top | -90deg |
การปรับแต่ง: ใช้ cubic-bezier สำหรับ bounce
.rotateIn-bounce {
animation: rotateIn 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
/* overshoot effect */
}