Recreating a CSS3 animation for Internet Explorer 9

While I am aware that CSS3 animations do not function properly in IE9 and below, I have managed to create a transition effect for a header that becomes fixed and shrinks in modern browsers with the following CSS:

/** This triggers when the viewport is scrolled down past 60px **/
.fm-container.small .branding {width:120px;transition: all 0.2s ease;}
.fm-container.small ul.prim-nav {margin-top:8px;transition: all 0.2s ease;}
.fm-container.small .prim-nav li ul a {font-size:100%;}
.fm-container.small .navicon:after {top:15px;transition: all 0.2s ease;}
.fm-container.small .highlight {opacity:0;}

/** This triggers when the viewport is at 0px from the top **/  
.fm-container.large .branding {width:200px;transition: all 0.2s ease;}
.fm-container.large ul.prim-nav {margin-top:30px;transition: all 0.2s ease;}
.fm-container.large .prim-nav li ul a {font-size:100%;}

Additionally, here is the jQuery code involved:

// Function for scrolling header
$(window).scroll(function() {    
    var scroll = $(window).scrollTop();
    // Apply class to animate size changes while scrolling
    if($(document).scrollTop()>60){
        $(".fm-container").removeClass("large").addClass("small");
    } else{
        $(".fm-container").removeClass("small").addClass("large");  
    }
});

My query revolves around making this animation work smoothly on all browsers, both old and modern, especially considering its limitations in IE9. Any guidance on improving this using jQuery would be highly appreciated.

I have attempted to modify it like so:

// Function for scrolling header
$(window).scroll(function() {    
    var scroll = $(window).scrollTop();
    // Apply class for animating size changes while scrolling
    if($(document).scrollTop()>60){
        $(".fm-container").removeClass("large").addClass("small");
        $(".fm-container.small").animate({width:"120px"});
        $(".fm-container.small ul.prim-nav").animate({marginTop:"8px"});
        $(".fm-container.small .navicon:after").animate({top:"15px"});
        $(".fm-container.small .highlight").animate({opacity:"0"});
    } else{
        $(".fm-container").removeClass("small").addClass("large");
        $(".fm-container.small").animate({width:"200px"});
        $(".fm-container.small ul.prim-nav").animate({marginTop:"30px"});
        $(".fm-container.small .navicon:after").animate({top:"12px"});
        $(".fm-container.small .highlight").animate({opacity:"1"});   
    }
});

However, this version does not revert back smoothly when scrolling to the top, and it feels quite rudimentary given my limited skills. I am eager to learn how to implement this correctly, so any assistance will be valued greatly.

Your support on this matter would be truly appreciated.

Answer №1

Everything is organized... I stumbled upon the following (I made necessary adjustments). Sharing it here in case it proves useful to anyone in the future.

$(window).scroll(function(){
        if($(document).scrollTop() > 33)
        {
            if($('.fm-container').data('size') == 'big')
            {
                $('.fm-container').data('size','small');
                $('.fm-container').stop().animate({height:'60px'},200);
                $('.branding').stop().animate({width:'120px'},200);
                $('.logo-spacer').stop().animate({width:'120px'},200);
                $('.fm-container ul.prim-nav').stop().animate({marginTop:'8px'},200);
                $('.fm-container .highlight').stop().animate({opacity:'0'},200);
            }
        }
        else
        {
            if($('.fm-container').data('size') == 'small')
            {
                $('.fm-container').data('size','big');
                $('.fm-container').stop().animate({height:'85px'},200);
                $('.branding').stop().animate({width:'200px'},200);
                $('.logo-spacer').stop().animate({width:'200px'},200);
                $('.fm-container ul.prim-nav').stop().animate({marginTop:'30px'},200);
                $('.fm-container .highlight').stop().animate({opacity:'1'},200);
            }  
        }
});

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

"Utilizing jQuery to apply conditional formatting to a table

Currently, I am working on a quiz that consists of 9 skills. One particular skill has 2 questions, making a total of 18 questions in the quiz. Upon submission of the quiz, the result table displays 4 different ranges (Rangea, b, c, d). Hence, based on the ...

Adding an event listener to the built-in arrow buttons on the `<input type=number>` element is a simple way to enhance user interaction

<input type="number" id="test"> I'm trying to figure out how to set an event listener for the two arrow buttons on the right of this number input field. Typically, we can use jQuery like: $("#test").on("cl ...

Experiencing a problem with a jQuery script when implementing third-party pagination on

I am setting up twbs pagination, but I am having trouble with the required script. <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> The existing code I have includes this script: <script src="https://code.jquery.com/jq ...

Utilizing the SmartSuggest jQuery plugin for seamless integration of JSON data

Recently, I acquired the jquery plugin named smart suggest and I am interested in feeding a json array as opposed to just an array. The existing data file, 'sample-data.php', displays: <?php $fruits = '{...}'; $vegetables = '{ ...

Update database upon drag-and-drop using jQuery

I have a dataset (shown below) that undergoes sorting by 'section'. Each item is placed into a UL based on its section when the page loads. My goal is to automatically update the section in the database when a user drags an item to a different s ...

Executing jQuery/Ajax load on each individual HTML page can be achieved by following a few simple steps

Can anyone help me with a coding issue I'm facing? I have multiple HTML pages where I include JavaScript scripts after the body tag. Initially, everything was working fine but as the project grew, it became messy to manage. To simplify things, I moved ...

Incorporating text overlays on images that are compatible with responsive websites is a top priority for me

This is a piece of HTML code that utilizes bootstrap 3 for design purposes. The challenge faced is related to positioning text over an image. When resizing the browser, the alignment of the text with the background gets disturbed. Assistance is needed in r ...

What is the best way to determine when all AJAX functions have finished loading on a webpage?

I am currently utilizing the SharePoint 2010 client object model on my page to execute asynchronous functions using ajax calls. Upon loading the page, I initiate numerous ajax calls to retrieve data. However, I am interested in finding a method where a s ...

Having trouble with @font-face not displaying in my style.css file

I've been scouring the internet in search of an answer to this dilemma, yet my quest has proved futile. Within my style.css file, I've utilized @font-face to incorporate a font (which I previously uploaded to my website's server) on my site. ...

Error message: Exceeded maximum call stack size when invoking Bootstrap modal within jQuery UI Dialog

I've encountered a unique issue that I need help with. Whenever I try to open a Bootstrap Modal while a jQuery UI Dialog is already open, I receive an error message in the console saying RangeError: Maximum call stack size exceeded. This problem only ...

Safari on Mac OS is experiencing issues with disappearing arrows

I am currently working on a WordPress website that utilizes the fullpage.js plugin (https://wordpress.org/plugins/wp-fullpage/). Encountering an issue with the fullpage's arrows (left and right) specifically on Safari on Mac OS: they appear and disap ...

Using VueJS transitions may require the use of setTimeout for them to work

My code successfully slides out a menu: Vue.set(this.filterStyles, filterIndex, { display: "block", height: "auto", }); let filterValuesElHeight; Vue.nextTick().then(() => { let filterValuesEl = document ...

Is there a function for displaying the message "User is currently typing"?

I've been working on a chat system in PHP/jQuery, where the message 'User is typing a message...' appears at the bottom. Despite trying numerous methods, I have yet to succeed. My chat system utilizes PHP, MySQL, Ajax, and jQuery. While I&a ...

I am currently developing a custom alert box component in Angular 9. While trying to modify the alert type, I have encountered an issue where the appropriate CSS class is not being assigned

I'm currently working on Angular 9 and facing an issue while trying to create a reusable alert component. The problem lies in the alert-box selector where setting the alert type does not change its appearance. Instead, only plain text is displayed wit ...

What is the method for implementing a personalized width for table headers with bootstrap/css?

I am facing an issue with applying custom width to each header of a table in my html. Despite having bootstrap4 integrated, the custom widths are not being applied. Below is the complete HTML code for the table: <div class="row"> <div class= ...

Is there a way to display a text area using JQuery without having to use an input field or opening it in a separate

After searching for ways to create a pop up text area, I discovered methods for input and new window popups. However, I am specifically seeking a solution where a text area smoothly appears upon clicking a button (likely using JQuery). Does anyone have a ...

The Ajax Success event fails to trigger when invoking a service

I am currently using JQuery to send an AJAX request to a local service. The local service is a HttpHandler named Request.ashx, which in turn calls an external website with CallExternalWebsite(). This is achieved through .NET's System.Net.WebRequest() ...

Angular reactive form CSS styling that necessitates the form to be both touched and invalid

Utilizing a reactive form for users to update their password. I aim to customize the input boxes to indicate any invalid submissions or errors. input.ng-invalid { border: 1px solid red; } An issue arises where the styling shows even before the user inte ...

Stopping the loop: Disabling the SetInterval function with ResponsiveVoice code in JavaScript

Currently, I am developing a queuing system and implementing voice announcements using Responsive Voice. I have used setInterval, but the issue is that the voice keeps looping without stopping. $( document ).ready(function() { setInterval(function() ...

Only conceal the breadcrumb trail on the 404 error page

I have recently created a custom node for my site's 404 page with the path /node/83 in the site information. However, I am facing an issue where I cannot hide the .breadcrumb element using display:none. I attempted to achieve this through CSS injector ...