debug: 添加平移调试信息
This commit is contained in:
parent
684367941d
commit
7ae58e98e6
|
|
@ -537,12 +537,17 @@ class _KlineChartWidgetState extends State<KlineChartWidget> {
|
|||
_userHasPanned = true; // 缩放后也标记为已操作
|
||||
} else if (_startFocalPoint != null) {
|
||||
// 单指平移
|
||||
// dx > 0 向右滑(看更早历史),dx < 0 向左滑(看更新数据)
|
||||
final dx = details.focalPoint.dx - _startFocalPoint!.dx;
|
||||
// 最大滚动位置:让最新K线在屏幕中心
|
||||
final int halfScreenCount = (_chartWidth / 2 / _candleWidth).ceil();
|
||||
final double maxScroll = math.max(0.0, (widget.klines.length - halfScreenCount) * _candleWidth);
|
||||
// 向右滑 dx>0,scrollX 减小,显示更早的数据
|
||||
_scrollX = (_startScrollX - dx).clamp(0.0, maxScroll);
|
||||
_userHasPanned = true;
|
||||
|
||||
// DEBUG: 打印滚动信息
|
||||
debugPrint('Pan: dx=$dx, scrollX=$_scrollX, maxScroll=$maxScroll, startIndex=${(_scrollX / _candleWidth).floor()}');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue