The hover effect is functional on the majority of browsers, with the exception of Safari and Chrome on a Mac computer

Within my html code, there are various tiles containing two images (one in jpg format as the background and one in png with transparency as the foreground) along with a hover effect: When hovering over a tile, the image zooms in towards the position of the cursor while the front image moves away from it.

As you move the cursor horizontally, all vertical images animate as well, and vice versa.

For reference, here's an example incorporating html, javascript, and css:

http://jsfiddle.net/Lmcn0sxw/6/

The hover effect is functional, despite some minor bugs.

The animations can be easily implemented using javascript and transform3d, where item represents the current tile with the .item class. Variables like topRatioFront are calculated based on the mouse position relative to the tile.

item.find('.front').css('transform', 'translate3d(0,' + topRatioFront + 'px,0)');
item.find('.back').css('transform', 'translate3d(0,' + topRatioBack + 'px,0)');

Different variations can be explored in the javascript code within the jsfiddle link provided.

The primary tile features animation through a matrix3d effect:

self.find(itemClass).css(
    'transform', 
    'matrix3d(1,0,0.00,' + leftRatio + ',0.00,1,0.00,' + topRatio + ',0,0,1,0,0,0,0,1)'
);

In my experience, this effect functions seamlessly in Google Chrome on Linux Mint and Windows, and though slightly less smoothly in Mozilla Firefox, it remains acceptable.

The Issue at Hand

Upon viewing the site on Safari running on a Mac, both my friend and I noticed significant lag in the animations - almost appearing jittery. Surprisingly, the same issue persisted on Chrome for Mac as well, however, not on Safari for Mac.

How can I go about diagnosing and rectifying this discrepancy? It seems unlikely that the performance of the computers used is the root cause, especially considering this site, which employs a similar effect but functions flawlessly across browsers irrespective of the OS.

My Attempts to Resolve

Initially, I switched from using translate to translate3d under the impression that the latter was quicker - unfortunately, this change yielded no improvement.

Subsequently, I introduced a function called requestAnimationFrame, designed to aid in rendering animations. However, the outcome remained unchanged.

A Secondary Predicament

Specifically when testing on Safari (version 8.0.7), the matrix3d transform works as expected, yet all other transforms fail to take effect, neither on the active tile nor on any others. Oddly enough, CanIUse suggests that Safari 8 does support transform3d. While inspecting the item with the matrix3d transform, I notice the update reflected in the DOM tree; however, none of the elements under .back or .front exhibit the added transform3d property, leaving me perplexed on how to address this issue.

Answer №1

I have identified the source of the lag you are experiencing as being related to this line of code: offset = self.offset(). By querying the DOM on each frame, you are forcing it to render the layout repeatedly, causing the stuttering effect. To resolve this issue, consider reading the offset value just once before starting the animations.

In addition, you can optimize performance by adding `will-change: transform` to each element before initiating the animation.

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

Looking for a full-page banner within the Genesis Wordpress framework?

I am currently working on a website utilizing the Genesis framework for WordPress. My main goal is to create a straightforward, full-width responsive layered banner. However, I have encountered an issue where this design is always confined within the cont ...

Is ES5 essentially the same as ES6 in terms of my lambda search?

After doing a search on an array using ES6, I am having trouble figuring out how to rewrite the code in ES5 due to restrictions with Cordova not allowing me to use lambda functions... $scope.Contact.title = $scope.doctitles[$scope.doctitles.findIndex(fu ...

What is the best way to extract the value from a Material UI Slider for utilization?

I am looking to capture the value of the slider's onDragStop event and store it as a const so that I can use it in various parts of my code. However, I am unsure about how to properly declare my const sliderValue and update it. Any guidance on where a ...

When using TypeScript in React, the event handler for the onLoad event of an image element cannot locate the properties naturalWidth and naturalHeight

https://i.sstatic.net/vPfkL.png return <img {...props} onLoad={event => { console.log(event.target.naturalWidth) }}/> I am encountering an issue trying to access naturalWidth and naturalHeight in TypeScript React. Unfortunately, TypeScript is ...

Modifying the CSS display property in Javascript following a media query update

Seeking a solution for a table that needs to be visible on desktop but hidden on mobile, with the option of clicking a button to toggle its visibility. Currently, the javascript function close_table() sets display:none which overrides the CSS display:block ...

Select two out of the three links from a repeating HTML structure using JQuery

Having difficulty creating an efficient jQuery selector to choose 2 out of 3 existing a elements within a repeating HTML structure. Below is the code snippet. The goal is to select Link 1, Link 2, excluding Link 3. Keep in mind that the entire HTML struct ...

What guidelines should be followed for utilizing jQuery's Ajax convenience methods and effectively managing errors?

Imagine a scenario where I am trying to mimic Gmail's interface using jQuery Ajax to incorporate periodic auto-saving and sending functionalities. Error handling is crucial, especially in cases of network errors or other issues. Instead of just being ...

"Discovering the active span tag in a webpage: A step-by-step guide

I have a main anchor tag with two span tags inside, each with a different class name as shown below. <a class="clickSlide" id="btnmain_login" href="/"> <span class="Icohide"></span> <span ...

Troubleshooting Next.js 13: Issues with Error and Not Found Pages Rendering Incorrectly

I am currently working on a project with the latest version of Next.js, specifically Next.js 13, and I have organized my app directory structure accordingly. Within the app/sample directory, I have implemented custom error handling by creating pages named ...

Alert! Server node encountered an issue while handling the response: process.nextTick(function(){throw err;});

Currently, I am working on a simple application to familiarize myself with Mongo, Express, and Node. An issue arises when I attempt to utilize res.json(docs) in the success conditional during the GET request, generating an error process.nextTick(function( ...

Uploading an image using ajax with multer

When using Multer to upload an image file to my Node server, I keep getting 'undefined' when trying to use ajax to send the image. Ajax : image = $("#input-file-img").val() const data = new FormData(); data.appe ...

Limiting the length of parameters in an Angular directive

Is there a character limit for the parameter being sent to this directive? I'm encountering an issue with my code: header = JSON.stringify(header); columnObj = JSON.stringify(columnObj); $compile('<div column-filter-sort header=' + heade ...

Guide on mocking a function inside another function imported from a module with TypeScript and Jest

I have a function inside the action directory that I want to test: import { Action, ActionProgress, ActionStatus, MagicLinkProgress } from '../../interfaces' import { areSameActions } from '../actionsProgress' export const findActionPr ...

Issue: Child Pages not found in Nuxt RoutingDescription: When navigating

Currently working on a Nuxt application that utilizes the WordPress REST API to fetch content. While my other routes are functioning correctly, I am facing challenges with nested pages. The structure I have implemented in my Nuxt app is as follows: pages ...

What is the best way to choose every single element on the webpage excluding a specific element along with all of its children?

Is there a way to hide all content on a page except for a specific element and its children using CSS? I've been exploring the :not selector, but I'm struggling to make it work with the * selector. :not(.list-app) { display: none; } :not(. ...

Leveraging the httponly cookie for transmitting JWT token between a Node REST API and a Vue.js SPA

I am currently in the process of developing a web application that utilizes a Vue.js frontend along with a Node REST API built using express. I am facing a challenge in implementing authentication, particularly in striving for a stateless approach by utili ...

changing unique characters in JavaScript document

I am currently utilizing DocXTemplater to export a table to a Word document. Within the JavaScript file, there is a module containing special characters that CRM does not permit when creating a file. I attempted to remove the variables with special charac ...

What could be the reason why Bootstrap Reboot is not functioning properly in ReactJS

After struggling for days and attempting various solutions found online, I still can't seem to get the bootstrap reboot to work in my reactjs project. I even attempted adding it directly into my public/index.html file: <link rel="stylesheet" hre ...

CSS - the option element is not appearing when using display:block

I am facing an issue with a select tag and its options. I have used CSS to hide all the options except for the last one which is set to display block. However, the last option is not showing up. Could this be due to the large number of options present? &l ...

The parameters for Vue.js @change events are consistently returning as 0 whenever a file is uploaded by clicking on the picture

Check out my JSFiddle here:: https://jsfiddle.net/includephone/o9gpb1q8 I've encountered an issue involving the @change event on an input field. My goal is to create a carousel of images with 4 images per slide. Data Object Structure data: functio ...