Slowly revealing sticky navigation with slideDown animation using JQuery

Here is the code for a .JS file:

 $(document).scroll(function (){
        var menuheight= $('header').height();
        var y = $(this).scrollTop();

      if (y>(menuheight))
       {

              $('.menu_nav_features').addClass('sticky');
       }

      else{
              $('.menu_nav_features').removeClass('sticky');
       }

 });

This is the CSS class that will be added on scroll down for a specific height:

 .sticky{
   position: fixed;
   top: 0;
  }

Contained in my .less file, here is the Navigation Bar code:

   .menu_nav_features{
       width: 100%;
       height: 46px !important;
       border-bottom: 1px solid #e6e6e6;
       border-top: 1px solid #e6e6e6;

    .menu-features{
        margin-top: 0px;
        width: 1200px !important;
        list-style:none;
        margin-left: -35px;
        li{
            display: inline;
            .transition;
            a{  
                background: #f4f4f4;
                margin-right:-3px;
                display: inline-block;
                text-decoration: none;
                color:#444444;
                padding:0px 30px;
                line-height: 44px;
                .transition;
            }
            a:active, a:hover{
                color: #000;
                background: #fdfdfd;
            }
        }
        li:nth-child(2):hover .bf{
            .displayall;
            .transition;
        }
        .bf{
            display: none;
            position: absolute;
            margin-left: 134px;
            padding-top: 7px;
            
            .bf_btns{

                a{
                    display: block;
                    width: 238px !important;
                }
                a:last-child{
                    margin-top: 0px;
                }
            }
        }
    }
 }

Problem Statement: When the scrollbar height exceeds the height of the header, the Navigation bar becomes fixed due to the Sticky class being applied. However, I want it to show slowly or use a slideDown effect using jQuery. I tried adding a transition to the Sticky class but it didn't work as expected.

Answer №1

To resolve this issue, a potential solution involves utilizing CSS

@keyframes scroll-up {
  from {transform: translate(0,-100%)}
  to {transfrom: translate(0,0)}
}
.sticky {
  position: fixed;
  top:0;
  animation-name: scroll-up;
  animation-duration: 0.4s;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to adjust a horizontal list of inline elements to stack vertically when the div container is resized?

Here is the issue I'm facing (notice how the yellow tiles are overflowing): (view image here) because my reputation points are not enough. The screenshot above illustrates how the small yellow rectangles are extending beyond the boundaries of the gr ...

Getting the nth-child rule for CSS in IE9 to function properly in IE8

This code is functioning in IE9: body.country-XYZ .abc:nth-child(3) { display:none; } As :nth-child() is effective in IE9 and newer versions, what can be done to ensure it also functions on IE8? Can you suggest an alternative method for achieving th ...

Retrieving the selected value from a Bootstrap dropdown using JavaScript when there are multiple dropdowns present

I have created multiple rows in javascript that are being rendered to the DOM from a Firestore collection. Each row contains a Bootstrap dropdown with the same select options (".a" elements). The id attribute of each row div is dynamically set based on the ...

"Request sent through Ajax can only be accepted by Localhost and specified IPs

Having an issue with my ajax post request. I want to post to a specific URL, but I also want it to accept both "localhost" and the IP address in the browser. If I set it up like this: $.ajax({ url: 'http://192.168.9.30/test/suma.php&ap ...

Issue: ENOENT - The specified file or directory cannot be found while scanning in a discord bot

Recently, I decided to try my hand at creating discord bots even though I am new to it. After watching a tutorial and copying the code, I encountered an error that has me stumped: node:internal/fs/utils:347 throw err; ^ Error: ENOENT: no such ...

Display solely the error message contained within the error object when utilizing the fetch API in JavaScript

I am facing an issue in logging the error message to the console while everything else seems to be working fine. Specifically, I am unable to log only the message such as "email exists" when the email already exists in the system. const submitHandler = a ...

Utilizing Knockout JS to populate a dropdown list with options fetched from a JSON object retrieved through an AJAX request

Seeking assistance with using knockout js for data binding in my single page web application. I am looking to populate a dropdown list by utilizing a json object returned as response from an ajax call to the server. Below is my model and ajax call code. An ...

Is it possible to maintain the sidebar while eliminating the scrolling JavaScript?

Looking to recreate the image display style on Facebook where pictures appear in a lightbox format. The challenge I'm facing is figuring out how they manage to have the sidebar with no visible scroll bar inside... If you want to see this for yourself ...

Managing project versions and branches with gulp as the source control system

As a beginner in node.js and gulp, I apologize for the simplicity of my question. I am embarking on a new jQuery project using node.js and gulp. Below is the structure of my directory and files: /root-pluign-directory | ---- dist (holds release f ...

Which symbol or character corresponds to the public "get symbol" method?

While going through some Typescript code, I came across a line that is giving me trouble to understand. const symbol = Symbol.for('symbolname'); class Something { public get [symbol]() { return true; } ... } I am confused abou ...

What is the best way to assign the result of a promise to a variable?

My code includes an async function that retrieves a value async fetchUserName(environment: string, itemName: string, authToken: string): Promise<any> { let result = await this.obtainDeviceName(environment, itemName, authToken); return ...

Using Spring Boot to create a multiple select feature with Materialize CSS

Currently engaged in a Spring Boot project utilizing Materialize CSS for the frontend. Everything runs smoothly when running the HTML file independently, with the Materialize CSS multiple select feature working perfectly. However, upon integrating the HTML ...

Looking to set up an event listener for a customized checkbox in a Kendo UI Grid column with Vue Js?

Can someone help me figure out why my method checkboxToggle() is not working when I click on the checkbox? Here is the code snippet: ` Methods:{ toggleTemplate(){ let template = `<label class="switch" > <input type= ...

How are JSON objects formatted when transmitted via URL?

Currently, I am utilizing AJAX to transmit a JSON object to a C# Handler. I'm curious if it's possible to pass the JSON data through a URL for debugging purposes, similar to how we used to include simple parameters in URLs. In the C# handler, th ...

php failure to execute included file

Hey there! I'm currently facing an issue with including a file that contains all of my 'head' information. My goal is to simplify and streamline my page by breaking it down. In my index.php file, here's what I did: <?php include & ...

Guide to adding the initial element in an array using Immutability Helpers

Looking to rearrange the elements in an array? The challenge is that it involves a link to the object. How can this be achieved using immutability helper? Below you will find my current code: state = { table: [['', '', ' ...

Capturing C# log data for JavaScript interactions

Can anyone provide recommendations on how to capture JavaScript interactions in a browser using C#? I am interested in developing a web crawler that can track these interactions, allowing me to search for potentially harmful calls. ...

Struggling to retrieve the Object from a JSON file located at a specific URL

Apologies if this comes across as naive, but my venture into javascript and json is just starting. I'm eager to access the JSON object from the twitter API after executing var myjson; $.getJSON('url of the Object', function(data) { ...

React-Tooltip trimming

Currently, I am facing a dilemma that requires some resolution. The issue at hand is related to the placement of React-Tooltip within the List element. Whenever it's positioned there, it gets clipped. On the other hand, placing it at the bottom isn&a ...

Exploring variations in error handling for JavaScript promises in Node.js depending on whether the error is synchronous or asynchronous

Exploring the nuances of promise error handling for thrown errors and exceptions in the promise executor, particularly in comparison to reject, within a node.js context. Differences in handling between reject and throw/exceptions are evident. Some source ...