My goal is to retrieve the top offset values of a series of elements on my webpage. I am cycling through each element and recording its top offset value like this:
$(elements).each(function() {
var element = $(this);
var offset = Math.floor($(element).offset().top);
console.log(offset);
}
When using Firefox, I am getting the following values:
458, 1023, 1625, 2274, 2746, 3072, 3398, 3823, 4388, 4930
However, Safari provides different values:
460, 718, 976, 1318, 1799, 1918, 2036, 2254, 2512, 2746
While the top offset of the first element is similar in both browsers, Safari displays varying values afterward. Some of Safari's values are illogical, such as reporting the top offset of an offscreen element in an 800px window as 718px.
When visually inspecting each element's position in Safari, the values align with what Firefox reports. Therefore, the webpage displays consistently in both browsers, but Safari returns distinctly different offset() values.
I have also experimented with using position() instead of offset(), and encountered the same discrepancy: the initial value is accurate in both browsers, but Safari's subsequent values are incorrect.
Regrettably, I am unable to disclose my code. Given this limitation, what could possibly be causing Safari to display such significant discrepancies in offset values?