Bottom Action Bar Transition

User
bottom action bar should have a small fade-in-up transition (0.3s)
Assistant
For a smooth fade-in-up transition (0.3s) on the bottom action bar, you can achieve this using CSS animations. Here's how you can do it:

### **CSS Approach**

.bottom-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    text-align: center;
    color: white;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.bottom-action-bar.active {
    opacity: 1;
    transform: translateY(0);
}

### **JavaScript (If you want to trigger it dynamically)**

document.addEventListener("DOMContentLoaded", () => {
    setTimeout(() => {
        document.querySelector(".bottom-action-bar").classList.add("active");
    }, 100);
});

This will ensure that when the page loads, the bottom action bar smoothly fades in and moves up into place within **0.3 seconds**.

If you're using **Vue.js**, you can use Vue's built-in transitions:

<template>
  <transition name="fade-up">
    <div v-if="showBar" class="bottom-action-bar">Your Content Here</div>
  </transition>
</template>

<script>
export default {
  data() {
    return {
      showBar: false
    };
  },
  mounted() {
    setTimeout(() => {
      this.showBar = true;
    }, 100);
  }
};
</script>

<style>
.fade-up-enter-active {
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}
.fade-up-enter-from {
  opacity: 0;
  transform: translateY(20px);
}
.fade-up-enter-to {
  opacity: 1;
  transform: translateY(0);
}
</style>

Would you like it to be triggered on a specific event, such as a button click? ๐Ÿš€

User
apply in below let lastScrollTop = 0;

$(window).scroll(function () {
if ($(window).width() > 767) { // Check if screen width is greater than 767px
const currentScroll = $(this).scrollTop();
const header1 = document.querySelector(".main-header"); // Replace with Header 1 class or ID
const header2 = document.querySelector(".sticky-header"); // Replace with Header 2 class or ID
const scrollHeight = $(document).height();
const scrollPosition = $(window).height() + currentScroll;

if (scrollPosition >= scrollHeight) {
// Hide sticky header when reaching the absolute bottom
header2.style.opacity = "0";
header2.style.display = "none";
} else {
if (currentScroll > lastScrollTop) {
// Scrolling down
// header1.style.display = "none";
header2.style.display = "flex";
header2.style.opacity = "1";
} else {
// Scrolling up
if (currentScroll === 0) {
// header1.style.display = "block";
header2.style.opacity = "0";
header2.style.display = "none";
}
}
}

lastScrollTop = currentScroll;
}
});

Assistant
You can add a fade-in-up transition (0.3s) to the `.sticky-header` when it appears. Here's the updated code:

### **Updated jQuery Code**

let lastScrollTop = 0;

$(window).scroll(function () {
    if ($(window).width() > 767) {  // Check if screen width is greater than 767px
        const currentScroll = $(this).scrollTop();
        const header1 = document.querySelector(".main-header"); // Replace with Header 1 class or ID
        const header2 = document.querySelector(".sticky-header"); // Replace with Header 2 class or ID
        const scrollHeight = $(document).height();
        const scrollPosition = $(window).height() + currentScroll;

        if (scrollPosition >= scrollHeight) {
            // Hide sticky header when reaching the absolute bottom
            header2.classList.remove("visible");
        } else {
            if (currentScroll > lastScrollTop) {
                // Scrolling down
                header2.classList.add("visible");
            } else {
                // Scrolling up
                if (currentScroll === 0) {
                    header2.classList.remove("visible");
                }
            }
        }

        lastScrollTop = currentScroll;
    }
});

### **CSS for Fade-In-Up Effect**

.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    text-align: center;
    color: white;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    display: none;
}

.sticky-header.visible {
    opacity: 1;
    transform: translateY(0);
    display: flex;
}

### **How It Works**
1. Initially, `.sticky-header` is hidden (`opacity: 0` and `transform: translateY(-20px)`).
2. When scrolling **down**, `.sticky-header` gets the `.visible` class, making it fade in and slide down smoothly.
3. When scrolling **up to the top**, `.sticky-header` is hidden again.

Would you like to trigger it only after a certain scroll distance? ๐Ÿš€

Leave a Comment

Your email address will not be published. Required fields are marked *