website: safari fixes

This commit is contained in:
nym21
2026-02-05 11:43:40 +01:00
parent 897aab032e
commit bbba8f4373
6 changed files with 27 additions and 25 deletions

View File

@@ -196,7 +196,6 @@ export function createChart({ parent, id: chartId, brk, fitContent }) {
timeScale: {
borderVisible: false,
enableConflation: true,
// conflationThresholdFactor: 8,
...(fitContent
? {
minBarSpacing: 0.001,
@@ -680,27 +679,31 @@ export function createChart({ parent, id: chartId, brk, fitContent }) {
/** @type {number} */ (data.at(-1)?.time) ?? -Infinity;
// Restore saved range or use defaults
const savedRange = getRange();
if (savedRange) {
ichart.timeScale().setVisibleLogicalRange({
from: savedRange.from,
to: savedRange.to,
});
} else if (fitContent) {
ichart.timeScale().fitContent();
} else if (
(minBarSpacingByIndex[idx] ?? 0) >=
/** @type {number} */ (minBarSpacingByIndex.quarterindex)
) {
ichart
.timeScale()
.setVisibleLogicalRange({ from: -1, to: data.length });
}
// Delay until chart has applied the range
// RAF for Safari compatibility
requestAnimationFrame(() => {
if (seriesGeneration !== generation) return;
initialLoadComplete = true;
blueprints.onDataLoaded?.();
const savedRange = getRange();
if (savedRange) {
ichart.timeScale().setVisibleLogicalRange({
from: savedRange.from,
to: savedRange.to,
});
} else if (fitContent) {
ichart.timeScale().fitContent();
} else if (
(minBarSpacingByIndex[idx] ?? 0) >=
/** @type {number} */ (minBarSpacingByIndex.quarterindex)
) {
ichart
.timeScale()
.setVisibleLogicalRange({ from: -1, to: data.length });
}
// Delay until chart has applied the range
requestAnimationFrame(() => {
if (seriesGeneration !== generation) return;
initialLoadComplete = true;
blueprints.onDataLoaded?.();
});
});
} else {
// Incremental update: only process new data points