Animation
by Marcos Moitas
HTML
<button onclick="openToast(5000)">Open</button>
<button onclick="closeToast()">Close</button>
<script>
var toastTimer;
function openToast(openTime) {
const element = document.getElementById("toast");
element.classList.add("wv-toast--open");
toastTimer = setTimeout(closeToast, openTime);
}
function closeToast() {
const element = document.getElementById("toast");
element.classList.remove("wv-toast--open");
clearTimeout(toastTimer);
}
</script>
<div class="wv-toast">
<div id="toast" class="wv-toast--closed">
<div class="wv-toast__content">
Copy goes here telling you what to do.
</div>
</div>
</div>
SCSS
.wv-toast {
width: 400px;
position: absolute;
top: 24px;
right: 0;
left: 0;
margin: 0 auto;
z-index: 1000px;
}
.wv-toast--closed {
transition-property: all 0.5s;
position: absolute;
left: 0;
bottom: 20px;
background-color: blue;
border-radius: 40px;
width: 720px;
transform: scale3d(0, 0, 0);
height: 0;
opacity: 0;
}
.wv-toast--open {
transform: scale3d(2, 1, 1);
top: 0;
left: 0;
border-radius: 12px;
opacity: 1;
}