Safari/IE lags when scrolling to the top of the page

I am attempting to keep an element fixed at the top position by using position:relative,

$(document).ready(function() {
    var container = $(".container");

    container.css("overflow-y", "auto");
    container.css("overflow-x", "hidden");

    container.on("scroll", function() {
        $("table", this).css("overflow-x", "hidden");
        $("th", this).css("position", "relative");
        $("th", this).css("z-index", 1);
        $("th", this).css("top", this.scrollTop + "px");
    });
});

An example of issues can be found here. It works well in Chrome and Firefox, but Safari and IE experience lag when scrolling. Does anyone know how to fix this issue specifically in Safari? I chose not to use absolute or fixed positions because my table is quite complex and calculating column widths on the fly would be challenging.

Answer №1

After testing on both Edge and IE, the results appear to be satisfactory. Check out the code here

function adjustTableHeaders(){
var container = $(".container");
$("table", this).css("overflow-x", "hidden");
$("th", this).css("z-index", 1);
container.find("th").each(function(i){
  var td = container.find("tbody tr:eq(0) td:eq("+i+")");
  $(this).css({
     "width": td.width(),
     "left": td.offset().left
  });
});}

Answer №2

One persistent issue I encounter when using Safari is the inability to fully resolve it. While including the "mousewheel" event may provide some assistance, it still fails to entirely rectify the problem.

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

Various image dimensions cause divs to shift unevenly

Here is the current setup: <div class="row"> <div class="col-md-4 content-column"> <img class="btn-center btn-desktop" src="images/buttons/btn-desktop.svg" alt="desktop button"> <h2 class="btn-deskt ...

The website takes forever to load on Internet Explorer and it keeps freezing

When attempting to access a certain website, there is a noticeable delay before the page actually loads (especially when using older versions of Internet Explorer). The issue does not occur with other web browsers. The website in question is a simple Word ...

Does Parsley.js offer a way to configure so that the parsley-success field is not added to an input if it should be completely ignored?

Currently, I am excluding one input and adding the success class (which is fine with me) $('form').parsley({ excluded: '[data-parsley-sum-total="all"]' }); However, there are several other inputs without any validations that I do not wa ...

Creating a unique icon using Jquery Mobile for a button in a PhoneGap application

Has anyone experienced issues with using a custom icon for a jQuery mobile button? I am having trouble as it is only showing a grey circle instead of the actual icon. The default icons work fine, though. Here is the code snippet from the index.html page: ...

Encountering an error where property 'onClicked' is not defined when attempting to utilize chrome.action or chrome.browserAction in Chrome

I am currently developing a Chrome extension that will automatically redirect me to a specific URL when I click on the browser action icon. Here is the code snippet that I am trying to implement: chrome.browserAction.onClicked.addListener However, I am ...

Combining table rows using the <td> class in JavaScript

I am currently working on refining the JS code to merge rows with common values and classes in a table. The existing code successfully merged common rows but failed to consider their classes. Snippet of the Table code: <tbody id="property_dtl_table_bo ...

Establish a pathway based on an item on the list

I need to create a functionality where I can click on a fruit in a list to open a new route displaying the description of that fruit. Can someone guide me on how to set up the route to the 'productDescription.ejs' file? app.js: const express = ...

Tips for configuring ejs data within the data attribute and processing it using client-side JavaScript

My aim is to transfer leaderboard information from the server to the client-side JavaScript. This is the code on my server side: const leaderboard = [[dog,cat],[car,bus],[foo,bar]] const toJson = JSON.stringify(leaderboard) res.render('gam ...

Can the @keyup event be utilized to target an input element within a customized component?

Hey there! I've been trying to target an input element within a custom component using v-on:keyup, but it seems like I'm having some trouble. <TextField label="Some Text" @keyup="updateLen" v-model="text" /> ...

What steps do I need to take in order to load the static folder from a CSS file?

Is there a way to load the static folder from a CSS file? I attempted to import using URL(), however, it was unsuccessful. I am looking to utilize the static path in order to apply a background to an element. .input_card:checked+.check-box { backgroun ...

"Prior to executing the sort function, the JavaScript array undergoes a

Update: It seems like the issue is related to how the chrome console handles object evaluation, as pointed out by jsN00b. original source I am currently sorting an array by name and then by age, and logging the array three times: First right after initia ...

Issues with pagination and navigation in Joomla when using the Swiper JS carousel with Bootstrap 5

Initially, I attempted to incorporate Swiper JS into my Joomla 4 template using Twitter Bootstrap 5. I connected it from CDN. If you visit this link: , you will see the desired layout from a Figma design: Screenshot However, I encountered some issues: A ...

Store the numeric value in JavaScript as a PHP integer

My goal is to obtain the width of the browser and then compare it as a PHP variable. However, the issue I am facing is that it is being saved as a string, and my attempts at parsing it to another variable only result in returning 0. $tam='<script& ...

How to handle multiple radio inputs and determine the checked value in Vue?

Currently, I am in the process of learning Vue.js and developing a basic poll generator. However, I have encountered an issue with radio inputs. In this application, each question can be of two types - 'select' or 'range.' 'Select ...

Navigating through multiple layers of React refs can be achieved using a technique called travers

Hey there, I'm currently working on extracting all the a tags from within the #header-nav section. const HeaderNav = (props) => { // setState const $target = useRef(null); const $component = $target.current.querySelectorAll('a'); return ...

Highcharts feature enhancement: Adjusting zIndex of legendItem on mouseover/mouseout

I have a chart that includes a 'total' sum value series alongside other values. My goal is to initially hide or place this 'total' column behind the others, and then bring it to the front when the series' legendItem is hovered ove ...

Alert Ajax/Javascript when the background PHP operation has finished

Here's the scenario - straightforward and concise : On Page A : An ajax request is made (to intermediate.php) which triggers a background process - let's call it back.php interm.php responds back.php continues its operation until completion, wh ...

Banner Placement

Is there a way to arrange 3 banners without using absolute positioning? I prefer to use relative positioning so that the footer doesn't overlap with the page. How can I achieve this layout? .bms { height: 810px; left: 0; position: absolute; ...

AngularJS Error: Attempting to access 'then' property of an undefined value

I have a function set up in my AngularJS service: var readFile = function (path, file) { console.info("Attempting to read the file with URI: " +path+ " "+file); $cordovaFile.checkFile(path, file).then(function (success) { ...

Tips for retrieving specific data from MongoDB using Node.js

Currently facing an issue working with Node.js, express, and mongodb when it comes to passing data between frontend and backend. Note: The code below represents middleware code for communication between frontend and backend. I have successfully retrieved ...