diff --git a/lib/ui/screens/timeline/timeline_screen.dart b/lib/ui/screens/timeline/timeline_screen.dart index 589be041..e90c8b98 100644 --- a/lib/ui/screens/timeline/timeline_screen.dart +++ b/lib/ui/screens/timeline/timeline_screen.dart @@ -1,7 +1,9 @@ import 'dart:async'; +import 'dart:math' as Math; import 'dart:ui'; import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; import 'package:wonders/common_libs.dart'; import 'package:wonders/logic/common/animate_utils.dart'; import 'package:wonders/logic/common/debouncer.dart'; diff --git a/lib/ui/screens/timeline/widgets/_scrolling_viewport.dart b/lib/ui/screens/timeline/widgets/_scrolling_viewport.dart index 802b9f34..ea19760e 100644 --- a/lib/ui/screens/timeline/widgets/_scrolling_viewport.dart +++ b/lib/ui/screens/timeline/widgets/_scrolling_viewport.dart @@ -57,28 +57,35 @@ class _ScalingViewportState extends State<_ScrollingViewport> { scheduleMicrotask(controller._handleResize); } _prevSize = context.mq.size; - return GestureDetector( - // Handle pinch to zoom - onScaleUpdate: controller._handleScaleUpdate, - onScaleStart: controller._handleScaleStart, - behavior: HitTestBehavior.translucent, - // Fade in entire view when first shown - child: Stack( - children: [ - // Main content area - _buildScrollingArea(context).maybeAnimate().fadeIn(), + return Listener( + onPointerSignal: (PointerSignalEvent e) { + if (HardwareKeyboard.instance.isControlPressed) { + controller._handleScaleUpdateMouse(((e as PointerScaleEvent).scale - 1) * 0.25); + } + }, + child: GestureDetector( + // Handle pinch to zoom + onScaleUpdate: controller._handleScaleUpdate, + onScaleStart: controller._handleScaleStart, + behavior: HitTestBehavior.translucent, + // Fade in entire view when first shown + child: Stack( + children: [ + // Main content area + _buildScrollingArea(context).maybeAnimate().fadeIn(), - // Dashed line with a year that changes as we scroll - IgnorePointerKeepSemantics( - child: AnimatedBuilder( - animation: controller.scroller, - builder: (_, __) { - return _DashedDividerWithYear(controller.calculateYearFromScrollPos()); - }, + // Dashed line with a year that changes as we scroll + IgnorePointerKeepSemantics( + child: AnimatedBuilder( + animation: controller.scroller, + builder: (_, __) { + return _DashedDividerWithYear(controller.calculateYearFromScrollPos()); + }, + ), ), - ), - ], - ), + ], + ), + ) ); } diff --git a/lib/ui/screens/timeline/widgets/_scrolling_viewport_controller.dart b/lib/ui/screens/timeline/widgets/_scrolling_viewport_controller.dart index 5c244106..3145f6ba 100644 --- a/lib/ui/screens/timeline/widgets/_scrolling_viewport_controller.dart +++ b/lib/ui/screens/timeline/widgets/_scrolling_viewport_controller.dart @@ -91,6 +91,10 @@ class _ScrollingViewportController extends ChangeNotifier { setZoom(details.scale * _zoomOnScaleStart); } + void _handleScaleUpdateMouse(double scale) { + setZoom( Math.max(0, Math.min(1, _zoom + scale)) ); + } + /// Maintain current yr when the app changes size void _handleResize() => jumpToYear(_currentYr.value); }