Tips for eliminating an unwanted jiggle effect when hovering over an element on a webpage

Looking for a way to eliminate the unsteady jiggling effect on hover over links in the left side section of the menu. This is not referring to the standard translation effect when hovering over links. To see the unwanted effect, try moving the mouse slowly over the very beginning of the link(s). Any ideas?

/* jQuery Storage API Plugin 1.7.4 https://github.com/julien-maurel/jQuery-Storage-API */
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e){function t(t){var r,i,n,o=arguments.length,s=window[t],a=arguments,u=a[1];if(2>o)throw Error("Minimum 2 arguments must be given");if(e.isArray(u)){i={};for(var f in u){r=u[f];try{i[r]=JSON.parse(s.getItem(r))}catch(c){i[r]=s.getItem(r)}}return i}if(2!=o){try{i=JSON.parse(s.getItem(u))}catch(c){throw new ReferenceError(u+" is not defined in this storage")}for(var f=2;o-1>f;f++)if(i=i[a[f]],void 0===i)throw new ReferenceError([].slice.call(a,1,f+1).join(".")+" is not defined in this storage");if(e.isArray(a[f])){n=i,i={};for(var m in a[f])i[a[f][m]]=n[a[f][m]];return i}return i[a[f]]}try{return JSON.parse(s.getItem(u))}catch(c){return s.getItem(u)}}function r(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1],u=s[2],f={};if(2>n||!e.isPlainObject(a)&&3>n)throw Error("Minimum 3 arguments must be given or second parameter must be an object");if(e.isPlainObject(a)){for(var c in a)r=a[c],e.isPlainObject(r)?o.setItem(c,JSON.stringify(r)):o.setItem(c,r);return a}if(3==n)return"object"==typeof u?o.setItem(a,JSON.stringify(u)):o.setItem(a,u),u;try{i=o.getItem(a),null!=i&&(f=JSON.parse(i))}catch(m){}i=f;for(var c=2;n-...
        
.hidden {
        display: none;
    }

    body {
        font: normal 1.0em Arial, sans-serif;

    }


    nav.pagedMenu {
        color: red;
        font-size: 2.0em;
        line-height: 1.0em;
        width: 8em;
        position: fixed; 
        top: 50px;
    }

    nav.pagedMenu ul {

        list-style: none;
        margin: 0;
        padding: 0;
    }

    nav.pagedMenu ul li {
        height: 1.0em;
        padding: 0.15em;
        position: relative;
        border-top-right-radius: 0em;
        border-bottom-right-radius: 0em;
        -webkit-transition: 
        -webkit-transform 220ms, background-color 200ms, color 500ms;
        transition: transform 220ms, background-color 200ms, color 500ms;
    }
    
    ... (CSS code continues)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<nav class="pagedMenu">
     <!-- Links -->
    </nav>

    <div id="pagination">
        <a href="#" id="prevPage" class="hidden">Previous</a>&nbsp;&nbsp;
        <a href="#" id="nextPage" class="hidden>Next</a>
        <span id="msg"></span>
    </div>

Jsfiddle here

Answer №1

I believe jQuery is unnecessary in this scenario

Swap out the following:

nav.pagedMenu ul li.hovered {
        -webkit-transform: translateX(1.5em);
        transform: translateX(1.5em);
}

nav ul li:hover a {
        transition: color, 1200ms;
        color: red;
}

With:

nav.pagedMenu ul li:hover a {
        transition: padding-left 500ms,color 1200ms;
        padding-left:1.5em;
        color: red;
    }

http://jsfiddle.net/dh7920rq/

The issue with your current setup is that when hovering over the <li>, it shifts right while the mouse remains in its original position, triggering

mouseout</code prematurely and causing an unintended effect.</p>

<p>If we modify the <code>padding-left
of the <a> instead of moving the <li>, the mouse will stay within the bounds of the <li>.

http://jsfiddle.net/dh7920rq/1/

Update:

To maintain the desired state as per the OP, consider using jQuery:

Replace:

nav.pagedMenu ul li.hovered {
        -webkit-transform: translateX(1.5em);
        transform: translateX(1.5em);
    }

nav ul li:hover a {
        transition: color, 1200ms;
        color: red;
}

With:

nav.pagedMenu ul li.hovered a{
        transition: margin-left 500ms,transition: color 1200ms;
        margin-left:1.5em;
        color: red;
    }

The concept remains consistent: http://plnkr.co/edit/880ZtUiCwbRNGBNGuURU?p=preview

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

Displaying Data in React Table from JavaScript Object

I'm working on a React component that will display a table of data from a JavaScript object called pixarMovies. The initial state is set with this object. My goal is to sort the movies chronologically by date and render them in a table format (refer t ...

What is the best way to create a tree structure in jQuery for organizing parent-child relationships within an unordered list (

Before <ul> <li parent-id="0" li-id="16">Anthropology Department</li> <li parent-id="16" li-id="18">Anthropology Faculty Collections</li> <li parent-id="16" li-id="23">Shared Collections</li> <li parent-id="0" ...

Transform inline styles in React to CSS declarations

Is there a tool available that can convert React inline style descriptions into CSS rules? For example: { minHeight: 200, position: 'relative', flexGrow: 1, flexShrink: 1, display: 'flex', flexDirection: ' ...

The integration of a webview within an Ionic application

I have developed a mobile app using the Ionic framework and now I am trying to incorporate a webview using Chrome browser instead of the default browser. Initially, I used the cordova-plugin-inappbrowser plugin but found it to be unstable. I then tried t ...

What is the process for uploading an image using Vue.js?

Looking for guidance on how to upload an image using Vue.js. This is my HTML code to insert a picture: <input type="file" id="wizard-picture"> And here is my Vue.js code: <script> submitBox = new Vue({ el: "#submitBox", data: { usernam ...

Showing a tooltip on the right side of a control with an arrow pointing towards it in a colored

Can someone help me with displaying a tooltip to the right end of a control, with the arrow facing the same direction and changing the background color of the arrow to red? Here is my attempt so far <input id="age" title="test tooltip"> $( documen ...

CSS dimensional changes

I am currently working on developing an application that involves incorporating a perspective map with the ability to add map markers represented by absolutely positioned DIVs. However, I seem to be encountering challenges related to transformations and 3D ...

selenium.common.exceptions.ElementNotInteractableException: Error: the element cannot be interacted with

My current programming project involves using selenium webdriver with Twitter for fun, but I've run into a frustrating issue. The problem arises when I attempt to input text into the tweet box: https://i.stack.imgur.com/Zxwvg.png To activate the ele ...

What strategies can I employ to prevent my div tags from shifting positions relative to each other?

I spent time formatting a div tag for my main content and then placed that div inside another wrapper div. However, when I tried to add my logo to the site, everything shifted. It appeared as though the div containing the logo had pushed the wrapper down. ...

Learn how to utilize AngularJS Material to toggle the enable/disable functionality of a checkbox

Can someone assist me in enabling and disabling the checkbox as shown in the attachment image https://i.stack.imgur.com/l6g1C.jpg View the PLNKR angular.module('BlankApp', ['ngMaterial']) .config(['$mdThemingProvider', fun ...

When working with Vuejs Composition API, I noticed that the value of a Reference object seems to disappear when I

Here is the code snippet that I am working with: <template> {{posts}} </template> <script> import { computed, ref } from 'vue'; import getPosts from '../composables/getPosts.js' import {useRoute} from 'vue-router ...

ERROR: The data has reached its end prematurely (data length = 0, requested index = 4). Could this be a corrupted zip file?

Currently, I am developing a WhatsApp bot and storing the chat data in an Excel file using exceljs for further processing. In order to handle responses efficiently, I am utilizing promises to resolve them. Below is the function I have created to read the c ...

Encountering an issue in XtermJS where it is unable to read properties of undefined, specifically 'dimensions', while being used with NextJs version 14

UPDATE: Additional Details useEffect(() => { // let terminal; if (terminalRef.current) { const terminal = new Terminal({ fontFamily: "Menlo, Monaco, monospace", // fontSize: 12, // cursorBlink: true, ...

Utilizing htmx for interactive elements throughout the website

When I make an htmx-request on my page, a loading spinner is displayed like this: <div class="col-4 px-4dot5 py-3 bg-secondary-light"> <label for="stellenangebotLink" class="form-label fs-5">Link</label> ...

What sets npm run apart from npm start?

Our repository contains a substantial amount of TypeScript code that we can compile and execute using "npm run dev." This setup enables us to access the test JavaScript code via localhost. However, when examining the code in the Chrome debugger, approxim ...

Hide, show, toggle, or empty elements using jQuery

I am having trouble getting this jQuery code to function properly. Within a div, there is a paragraph that I want to hide when a specific button is clicked and show when another button is clicked. Check out the code here $("#details").on("c ...

Acquire a JSON response from a web address by utilizing JavaScript

If you navigate to , you will find a JSON file filled with information about your current geolocation. My goal is to save this JSON data into JavaScript variables, allowing me to manipulate and extract specific fields from the file. ...

Retrieving the data input from a datalist and using v-model will automatically reset the datalist

Looking for a way to preserve options in a datalist after selecting one using v-model in Vue. Currently, the selected option clears all other options due to two-way binding. Is there a method to only capture the selected value without removing the rest of ...

Can you explain the process of utilizing CSS to create a smooth transition effect with

In the example application, I am utilizing the following plugin: I am perplexed by this line of code: style="width: 538px; transition: opacity 10000ms cubic-bezier(0.42, 0.65, 0.27, 0.99) 0s;. Can someone explain how the transition works? From what ...

Press the button to move to the following node

Is there a way to call a function on an image tag's click event without using a specific id, as the image tag has dynamic ids and I cannot directly use 'on-click'? I have tried the jQuery code below but it didn't work. Are there any oth ...