debug: 添加平移调试信息

This commit is contained in:
hailin 2026-01-19 21:30:41 -08:00
parent 684367941d
commit 7ae58e98e6
1 changed files with 5 additions and 0 deletions

View File

@ -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>0scrollX
_scrollX = (_startScrollX - dx).clamp(0.0, maxScroll);
_userHasPanned = true;
// DEBUG:
debugPrint('Pan: dx=$dx, scrollX=$_scrollX, maxScroll=$maxScroll, startIndex=${(_scrollX / _candleWidth).floor()}');
}
});
}