The transition property in CSS and JavaScript does not seem to be functioning properly in Firefox

Recently, I integrated a Slide in menu script on my website using a Slide in menu script. After following all the instructions provided, the menu started working flawlessly on Chrome and Safari browsers. However, my main goal was to make it function on Firefox as well. I attempted various modifications to the CSS and JavaScript files to troubleshoot the compatibility issue with Firefox. To debug further, I added alert() statements within the JavaScript code to verify the execution flow, but everything seemed to be in order. Below is the complete set of code consisting of HTML, JavaScript, and CSS:

HTML page

<html>
<head>

<link rel="stylesheet" type="text/css" href="css/new.css">
<script type="text/javascript" src="js/slideinmenu.js"></script>

<script type="text/javascript"> 
var menu;
function loaded() {
    document.addEventListener('touchmove', function(e){ e.preventDefault(); 

e.stopPropagation(); });
    menu = new slideInMenu('slidedownmenu', true);
}
document.addEventListener('DOMContentLoaded', loaded);
</script>
</head>

<body>
<div id="slidedownmenu">
    <ul>
        <li>Option 1</li>
        <li>Option 2</li>
        <li>Option 3</li>
        <li>Option 4</li>
    </ul>
    <div class="handle"></div>
</div>

<div id="content">


    <p>Click to <a href="#" onclick="menu.open();return false">Open</a>, <a 

href="#" onclick="menu.close();return false">Close</a> and <a href="#" 

onclick="menu.toggle();return false">Toggle</a> the menu programmatically.</p>
</div>

</body>
</html>

The JavaScript section

 function slideInMenu (el, opened) {
    this.container = document.getElementById(el);
    this.handle = this.container.querySelector('.handle');
    this.openedPosition = this.container.clientHeight;
    this.container.style.opacity = '1';
    this.container.style.top = '-' + this.openedPosition + 'px';
    this.container.style.webkitTransitionProperty = '-webkit-transform';
    this.container.style.webkitTransitionDuration = '400ms';
    if ( opened===true ) {
        this.open();
    }
    this.handle.addEventListener('touchstart', this);
}
slideInMenu.prototype = {
    pos: 0,
    opened: false,
    handleEvent: function(e) {
        switch (e.type) {
            case 'touchstart': this.touchStart(e); break;
            case 'touchmove': this.touchMove(e); break;
            case 'touchend': this.touchEnd(e); break;
        }       
    },
    setPosition: function(pos) {
        this.pos = pos;
        this.container.style.webkitTransform = 'translate(0,' + pos + 'px)';
        if (this.pos == this.openedPosition) {
            this.opened = true;
        } else if (this.pos == 0) {
            this.opened = false;
        }
    },
    open: function() {
        this.setPosition(this.openedPosition);
    },
    close: function() {
        this.setPosition("0");
    },
    toggle: function() {
        if (this.opened) {
            this.close();
        } else {
            this.open();
        }
    }
}

CSS Styles


a{
    color:#ffc;
}
ul, li, div {
    margin:0;
    padding:0;
    list-style:none;
}
#content {
    padding:40px 10px 10px 10px;
    text-align:center;
    text-shadow:0 1px 1px #000;
    font-size:1.2em;
}
#slidedownmenu {
    position:absolute;
    width:100%;
    height:115px;
    left:0;
    background:black url(drawer-bg.jpg);
}
#slidedownmenu .handle {
    position:absolute;
    bottom:-28px;
    left:0;
    width:100%;
    height:28px;
    border-top:1px solid #532500;
    border-bottom:1px solid #111;
    background-color:maroon;
    background:url(handle.png) no-repeat 50% 50%, -webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #e07b29), color-stop(0.1, #b85300), color-stop(0.8, #793600));
/*  -webkit-box-shadow:0 0 5px rgba(0,0,0,0.7);*/
}
#slidedownmenu ul {
    display:block;
    width:auto;
}
#slidedownmenu li {
    display:block;
    float:left;
    margin:20px 10px;
    text-align:center;
    font-weight:bold;
    color:#fff;
    text-shadow:0 1px 1px #000;
}

I would greatly appreciate any suggestions or insights regarding this issue.

Answer №1

I have discovered the resolution to the issue mentioned above. While webkit is specifically for Safari, standard syntax is also supported by Firefox, Chrome, and Internet Explorer 10. In the JavaScript code snippet provided:

   this.container.style.webkitTransitionProperty = '-webkit-transform';

has been replaced with:

  this.container.style.transitionProperty = 'transform';

Similarly, the following lines:

  this.container.style.webkitTransitionDuration = '400ms';

have been changed to:

  this.container.style.transitionDuration = '400ms';

And:

this.container.style.webkitTransform = 'translate(0,' + pos + 'px)';

has been updated to:

this.container.style.transform = 'translate(0,' + pos + 'px)';

As a result, the code now functions correctly in the Firefox desktop browser. By adhering to standard syntax rather than relying on webkit properties, the transitions now work smoothly in Firefox. It is important to use standard CSS syntax when facing transition issues in Firefox, as demonstrated by my successful testing on desktop Firefox (although performance may vary on mobile Firefox).

Answer №2

Attempting to eliminate the /* and */ from the webkit line in hopes that it will function properly. However, it seems that this feature is not universally available across all browsers.

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

How can I create a regex pattern that will exclude characters within parentheses?

While working on some regex, I encountered a bug: The scenario is as follows: I have this string - for example "+1/(1/10)+(1/30)+1/50" and I applied the regex /\+.[^\+]*/g to it, which worked perfectly giving me ['+1/(1/10)&apos ...

Testing a Jest unit on a function that invokes another function which in turn returns a Promise

I have a function that triggers another function which returns a Promise. Below is the code snippet for reference: export const func1 = ({ contentRef, onShareFile, t, trackOnShareFile, }) => e => { trackOnShareFile() try { func2(conte ...

The modal box should adjust its height to perfectly accommodate the content within

I'm in the process of developing a straightforward modal (popup) window, using as few lines of code as possible... just the basics. The modal has a maximum width of 650px and its height adjusts to fit the content. In case the content exceeds the avai ...

Is it possible to utilize a contenteditable div in place of a textarea?

Is it possible to replace a textarea with a content editable div? Will the behavior be the same? Can data processing be done in the same way as with textarea data? ...

"Hiding elements with display: none still occupies space on the

For some reason, my Pagination nav is set to display:none but causing an empty space where it shouldn't be. Even after trying overflow:hidden, visibility:none, height:0, the issue persists. I suspect it might have something to do with relative and ab ...

Mocha: A Unique Perspective on Testing the express.Router Instance

As I was developing a JavaScript controller file, I came across the need to test if my controller instance contains an instance of the express method called Router(). import {assert} from 'chai'; import {UF_Controller} from '../../controlle ...

Update the JavaScript to modify the styling based on the specific value of the

Is there a way to apply specific style properties to images only if they already have another property? I've managed to achieve this with the following code snippet: if ($('#content p img').css('float') == 'right') $ ...

Mobile view causes malfunction in Bootstrap Toggle Burger Menu functionality

<nav class="navbar navbar-expand-lg navbar-dark px-2 " style="background-color:#E53935;"> <a class="navbar-brand" href="#">FoodFusion</a> <button class=&quo ...

Implementing closure within a recursive function allows for better control

One of my functions is designed to take a parameter and print the last number in the Fibonacci Series. For example, if the parameter is 3, it would return 2 as the series progresses like 1, 1, 2. function recursionFib(num){ if(num ...

I am interested in updating the color of the active item on the navbar

I am looking to modify the color of the active page, Here is the HTML code snippet: <html> <head> <title>John Doe - Portfolio</title> <link rel="stylesheet" href="custom-style.css"> <link rel=" ...

React - Uncaught Error: e.preventDefault is not a function due to Type Error

Encountering an issue with Axios post and react-hook-form: Unhandled Rejection (TypeError): e.preventDefault is not a function The error arises after adding onSubmit={handleSubmit(handleSubmitAxios)} to my <form>. Seeking to utilize react-hook-form ...

Implement a basic JavaScript prompt feature within a Node.js application that can be integrated into

My Angular App is wrapped by electron and utilizes node.js to fetch MySQL data for AngularJs via electron. However, since there is no fixed database in my project, I have to dynamically change the database credentials from the client side, making sure it p ...

Is it possible to identify if an array is a polygon or multipolygon by examining its GeoJson data?

Recently, I came across an example illustrating a simple polygon. However, I wanted to display countries with complex polygons (multipolygons for some countries). Let me demonstrate the process: Example: "type": "Feature", "properties": { "Na ...

Updating Kendo by modifying the Angular model

While working on a project with Angular, I recently discovered the Kendo-Angular project available at . I successfully integrated Angular-Kendo into my project and it seems to be functioning well, except for updating models in the way I am accustomed to. ...

Guide to vertically aligning text in an overlay using CSS within Angular 2

I currently have an overlay on my page that displays a spinner (an Angular material component) and accompanying text. This overlay covers the entire page and prevents clicking on elements below it. The spinner is positioned in the center of the page, and ...

Cannot Get jQuery .flip() to Work Automatically Every 2 Seconds

There are 3 words that I want to rotate on their x-axis every 2 seconds (repeating). Using jQuery: $(function () { count = 0; wordsArray = ["Innovation", "Creativity", "Success"]; setInterval(function () { count++; $("#words").text(wordsArray[co ...

What is the method for invoking a JSON web service with jQuery that necessitates basic authentication?

My knowledge of javascript is limited, but I am attempting to access a JSON web service that requires basic authentication using jQuery. Unfortunately, my searches on Google have not yielded any useful results. Can anyone tell me if what I am trying to a ...

Error: The route cannot be established within an asynchronous function

The following code snippet is from the api.js module, responsible for creating a test route: 'use strict'; module.exports = function (app) { console.log("before route creation"); app.get("/api/test", (req, res) => { ...

Remove hidden data upon moving cursor over table rows after a delay

Hey there! I'm in need of a little assistance, so I hope you can lend me a hand. Here's the scenario: Within my category table, there are numerous rows, each containing a hidden textbox with an empty value and a unique ID. As users navigate t ...

JQGrid is a unique event grid that triggers only once for the inaugural loading, allowing users to apply a default filter upon first loading

I am currently using JQGrid (jQuery jQgrid not Gurrido) version 4.6.0 and I am in need of an event that occurs only once the grid has completed loading for the first time. I have attempted to use loadComplete and gridComplete, but it seems they both perfor ...