v0.1

Visibilidad condicional
#98 - Age Gating
Haga que los usuarios confirmen su edad antes de continuar.
Muestre cajas de tostadas personalizadas al hacer clic en un elemento
Watch the video for step-by-step implementation instructions
<!-- 馃挋 MEMBERSCRIPT #21 v0.1 馃挋 CUSTOM TOAST BOXES -->
<script>
document.addEventListener("DOMContentLoaded", function() {
聽const toastTriggers = document.querySelectorAll("[ms-code-toast-trigger]");
聽toastTriggers.forEach(trigger => {
聽 聽trigger.addEventListener("click", function() {
聽 聽 聽const triggerId = trigger.getAttribute("ms-code-toast-trigger");
聽 聽 聽const toastBox = document.querySelector(`[ms-code-toast-box="${triggerId}"]`);
聽 聽 聽if (toastBox) {
聽 聽 聽 聽const fadeInDuration = 200;
聽 聽 聽 聽const fadeOutDuration = 200;
聽 聽 聽 聽const staticDuration = 2000;
聽 聽 聽 聽const totalDuration = fadeInDuration + staticDuration + fadeOutDuration;
聽 聽 聽 聽toastBox.style.opacity = " number0";
聽 聽 聽 聽toastBox.style.display = "block";
聽 聽 聽 聽let currentTime = 0;
聽 聽 聽 聽const fade = function() {
聽 聽 聽 聽 聽currentTime += 10;
聽 聽 聽 聽 聽const opacity = currentTime < fadeInDuration
聽 聽 聽 聽 聽 聽? currentTime / fadeInDuration
聽 聽 聽 聽 聽 聽: currentTime < fadeInDuration + staticDuration
聽 聽 聽 聽 聽 聽 聽? 1
聽 聽 聽 聽 聽 聽 聽: 1 - (currentTime - fadeInDuration - staticDuration) / fadeOutDuration;
聽 聽 聽 聽 聽toastBox.style.opacity = opacity;
聽 聽 聽 聽 聽if (currentTime < totalDuration) {
聽 聽 聽 聽 聽 聽setTimeout(fade, 10);
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽toastBox.style.display = "none";
聽 聽 聽 聽 聽}
聽 聽 聽 聽};
聽 聽 聽 聽fade();
聽 聽 聽}
聽 聽});
聽});
});
</script>More scripts in Conditional Visibility