Anime Scale Bounce Modal
anime.jsの弾性イージングでバウンスしながら登場するモーダル。
HTML
<button class="asbm-trigger" id="asbm-trigger">Open Modal</button>
<div class="asbm-overlay" id="asbm-overlay">
<div class="asbm-modal" id="asbm-modal">
<h3>Bouncy Modal</h3>
<p>Elastic entrance animation</p>
<button class="asbm-close" id="asbm-close">Close</button>
</div>
</div>
CSS
.asbm-trigger {
padding: 12px 28px;
background: #6366f1;
color: #fff;
border: none;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
font-family: inherit;
cursor: pointer;
}
.asbm-overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.5);
display: none;
align-items: center;
justify-content: center;
z-index: 100;
}
.asbm-overlay.active { display: flex; }
.asbm-modal {
background: #1e293b;
padding: 32px;
border-radius: 16px;
color: #e2e8f0;
text-align: center;
transform: scale(0);
}
.asbm-modal h3 { margin: 0 0 8px; font-size: 20px; }
.asbm-modal p { margin: 0 0 20px; font-size: 13px; opacity: 0.7; }
.asbm-close {
padding: 8px 20px;
background: #334155;
color: #e2e8f0;
border: none;
border-radius: 6px;
font-size: 13px;
font-family: inherit;
cursor: pointer;
}
JavaScript
const trigger = document.getElementById('asbm-trigger');
const overlay = document.getElementById('asbm-overlay');
const modal = document.getElementById('asbm-modal');
const close = document.getElementById('asbm-close');
trigger.addEventListener('click', function() {
overlay.classList.add('active');
anime({
targets: modal,
scale: [0, 1],
duration: 600,
easing: 'easeOutElastic(1, 0.5)'
});
});
close.addEventListener('click', function() {
anime({
targets: modal,
scale: [1, 0],
duration: 300,
easing: 'easeInCubic',
complete: function() { overlay.classList.remove('active'); }
});
});