Maintain timeline year when resizing window
This commit is contained in:
parent
fbd6bdaa9b
commit
38dc787e27
@ -26,6 +26,7 @@ class _ScalingViewportState extends State<_ScrollingViewport> {
|
|||||||
late final _ScrollingViewportController controller = _ScrollingViewportController(this);
|
late final _ScrollingViewportController controller = _ScrollingViewportController(this);
|
||||||
static const double _minTimelineSize = 100;
|
static const double _minTimelineSize = 100;
|
||||||
final _currentEventMarker = ValueNotifier<TimelineEvent?>(null);
|
final _currentEventMarker = ValueNotifier<TimelineEvent?>(null);
|
||||||
|
Size? _prevSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -52,6 +53,10 @@ class _ScalingViewportState extends State<_ScrollingViewport> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
if (_prevSize != null && _prevSize != context.mq.size) {
|
||||||
|
scheduleMicrotask(controller._handleResize);
|
||||||
|
}
|
||||||
|
_prevSize = context.mq.size;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
// Handle pinch to zoom
|
// Handle pinch to zoom
|
||||||
onScaleUpdate: controller._handleScaleUpdate,
|
onScaleUpdate: controller._handleScaleUpdate,
|
||||||
|
@ -90,4 +90,7 @@ class _ScrollingViewportController extends ChangeNotifier {
|
|||||||
void _handleScaleUpdate(ScaleUpdateDetails details) {
|
void _handleScaleUpdate(ScaleUpdateDetails details) {
|
||||||
setZoom(details.scale * _zoomOnScaleStart);
|
setZoom(details.scale * _zoomOnScaleStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Maintain current yr when the app changes size
|
||||||
|
void _handleResize() => jumpToYear(_currentYr.value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user