🐕
【GSAP】GSAP Practice【#11 GSAP Sample3 Drower Menu Animation】
【#11 GSAP Sample3 Drower Menu Animation】
YouTube: https://youtu.be/7VvIWGbSwiU
今回はGSAPを使用して、
ドロワーメニューを作成していきます。
まずは、HTMLとCSSの部分を実装します。
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gsap practice</title>
<link
href="https://cdn.jsdelivr.net/npm/remixicon@4.5.0/fonts/remixicon.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<div class="section-1">
<div id="loading">Loading</div>
</div>
<div class="section-2">
<div id="stroke-wrapper">
<svg height="400" width="1000">
<path
d="M 20 150 Q 480 150 980 150"
stroke="white"
fill="transparent"
/>
</svg>
</div>
</div>
<div class="section-3">
<nav class="sec3-nav">
<div class="sec3-logo">GSAP Lesson</div>
<i id="menu-open" class="ri-menu-line"></i>
<div class="menu-bg"></div>
<div class="menu-wrapper">
<div class="menu-header">
<h3>Menu</h3>
<i id="menu-close" class="ri-close-line"></i>
</div>
<div class="menu-line"></div>
<ul class="menu-list-wrapper">
<li class="menu-list">TOP</li>
<li class="menu-list">CONTENT</li>
<li class="menu-list">ABOUT</li>
<li class="menu-list">CONTACT</li>
<li class="menu-list">ACCESS</li>
</ul>
</div>
</nav>
</div>
<script src="https://unpkg.com/lenis@1.1.16/dist/lenis.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/ScrollTrigger.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>
css/main.css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
}
.section-1,
.section-2,
.section-3 {
width: 100%;
height: 100vh;
}
.section-1 {
background-color: salmon;
display: flex;
flex-direction: column;
gap: 20px;
align-items: center;
justify-content: center;
}
#loading {
color: white;
font-size: 60px;
display: flex;
}
#loading span {
display: block;
}
.section-2 {
background-color: skyblue;
display: flex;
flex-direction: column;
gap: 20px;
align-items: center;
justify-content: center;
}
#stroke-wrapper {
width: 1000px;
margin: 0 auto;
background-color: gray;
}
.section-3 {
background-color: violet;
display: flex;
flex-direction: column;
position: relative;
}
.sec3-nav {
width: 100%;
max-width: 1560px;
margin: 0 auto;
padding: 20px;
display: flex;
align-items: center;
justify-content: space-between;
}
.sec3-logo {
font-weight: bold;
font-size: 24px;
}
.ri-menu-line,
.ri-close-line {
font-size: 24px;
cursor: pointer;
font-weight: 500;
}
.menu-wrapper {
height: 100%;
width: 320px;
position: absolute;
top: 0;
right: 0;
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
}
.menu-header {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 30px;
}
.menu-line {
width: 100%;
height: 1px;
margin: 14px 0;
background-color: rgba(255, 255, 255, 1);
}
.menu-list-wrapper {
list-style-type: none;
display: flex;
flex-direction: column;
gap: 20px;
font-size: 22px;
}
.menu-bg {
width: 100%;
height: 100%;
position: absolute;
top: 0;
right: 0;
background-color: rgba(255, 77, 0, 0.6);
}
.box {
width: 160px;
height: 160px;
display: flex;
align-items: center;
justify-content: center;
color: white;
}
.box-1 {
background-color: red;
}
.box-2 {
background-color: blue;
}
.box-3 {
background-color: green;
}
.box-4 {
background-color: purple;
}
Discussion