Respect manual chart zoom when auto-follow is off.
Tie the market auto toggle to both price scale and viewport: tail refresh updates data silently while preserving zoom/pan when auto is disabled. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 中控行情区:K 线 + 成交量;Hub 后台轮询 + SSE 推送;价格轴「自动」。
|
||||
* 中控行情区:K 线 + 成交量;Hub 后台轮询 + SSE 推送;「自动」控制价格轴与视口跟随。
|
||||
*/
|
||||
(function () {
|
||||
const AUTO_REFRESH_MS = 5000;
|
||||
@@ -2255,22 +2255,27 @@
|
||||
applyChartPriceFormat();
|
||||
}
|
||||
}
|
||||
const autoFollow = priceAutoScale;
|
||||
const shouldPreserve =
|
||||
savedRange &&
|
||||
isVisibleRangeValidForCandles(savedRange, candleCountBefore) &&
|
||||
(chartRangeUserLocked || !wasViewingTail);
|
||||
(!autoFollow || chartRangeUserLocked || !wasViewingTail);
|
||||
applyCandlesToChart(
|
||||
mergeCandles(lastCandles, alignCandlesToTick(data.candles), { prepend: false }),
|
||||
0,
|
||||
{
|
||||
preserveRange: !!shouldPreserve,
|
||||
skipAutoScale: chartRangeUserLocked,
|
||||
skipAutoScale: !autoFollow,
|
||||
}
|
||||
);
|
||||
if (epochAtStart !== chartViewEpoch) return;
|
||||
const n = lastCandles.length;
|
||||
const minorTailUpdate = Math.abs(n - candleCountBefore) <= CHART_TAIL_REFRESH_LIMIT + 5;
|
||||
if (wasViewingTail && !chartRangeUserLocked) {
|
||||
if (!autoFollow) {
|
||||
if (savedRange && isVisibleRangeValidForCandles(savedRange, n)) {
|
||||
restoreVisibleLogicalRange(savedRange, n);
|
||||
}
|
||||
} else if (wasViewingTail && !chartRangeUserLocked) {
|
||||
restoreVisibleLogicalRange(tailVisibleLogicalRange(n), n);
|
||||
} else if (shouldPreserve && minorTailUpdate) {
|
||||
if (!restoreVisibleLogicalRange(savedRange, n) && !chartRangeUserLocked) {
|
||||
@@ -2659,6 +2664,7 @@
|
||||
elPriceAuto.addEventListener("click", function () {
|
||||
priceAutoScale = !priceAutoScale;
|
||||
applyPriceAutoScale();
|
||||
if (priceAutoScale) applyDefaultVisibleRange();
|
||||
});
|
||||
}
|
||||
if (elPosClear) {
|
||||
|
||||
@@ -179,7 +179,7 @@
|
||||
</div>
|
||||
<div id="market-price-tag-time" class="market-price-tag-time"></div>
|
||||
</div>
|
||||
<button type="button" id="market-price-auto" class="market-price-auto is-on" title="价格轴自动缩放">自动</button>
|
||||
<button type="button" id="market-price-auto" class="market-price-auto is-on" title="开启:价格轴与视口随刷新自动调整;关闭:后台静默更新,保留当前缩放">自动</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user