Unverified Commit e122238c authored by TerrenceAddison's avatar TerrenceAddison Committed by GitHub

Bug fix where MouseScrollWheel zoom in flutter-web does not execute...

Bug fix where MouseScrollWheel zoom in flutter-web does not execute onInteraction functions (#65313)
parent f78b27e4
......@@ -65,3 +65,4 @@ CaiJingLong <cjl_spy@163.com>
Alex Li <google@alexv525.com>
Ram Navan <hiramprasad@gmail.com>
meritozh <ah841814092@gmail.com>
Terrence Addison Tandijono(flotilla) <terrenceaddison32@gmail.com>
......@@ -746,6 +746,7 @@ class _InteractiveViewerState extends State<InteractiveViewer> with TickerProvid
rotation: details.rotation,
));
}
final Offset focalPointScene = _transformationController.toScene(
details.localFocalPoint,
);
......@@ -918,6 +919,22 @@ class _InteractiveViewerState extends State<InteractiveViewer> with TickerProvid
_transformationController.value,
focalPointSceneScaled - focalPointScene,
);
if (widget.onInteractionStart != null) {
widget.onInteractionStart(
ScaleStartDetails(focalPoint: focalPointSceneScaled)
);
}
if (widget.onInteractionUpdate != null) {
widget.onInteractionUpdate(ScaleUpdateDetails(
rotation: 0.0,
scale: scaleChange,
horizontalScale: 1.0,
verticalScale: 1.0,
));
}
if (widget.onInteractionEnd != null) {
widget.onInteractionEnd(ScaleEndDetails());
}
}
}
......
......@@ -623,6 +623,46 @@ void main() {
expect(transformationController.value.getMaxScaleOnAxis(), equals(1.0));
});
testWidgets('Scale with mouse returns onInteraction properties', (WidgetTester tester) async{
final TransformationController transformationController = TransformationController();
double scaleChange;
Velocity currentVelocity;
bool calledStart;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: InteractiveViewer(
transformationController: transformationController,
onInteractionStart: (ScaleStartDetails details){
calledStart = true;
},
onInteractionUpdate: (ScaleUpdateDetails details){
scaleChange = details.scale;
},
onInteractionEnd: (ScaleEndDetails details){
currentVelocity = details.velocity;
},
child: Container(width: 200.0, height: 200.0),
),
),
),
),
);
final Offset center = tester.getCenter(find.byType(InteractiveViewer));
await scrollAt(center, tester, const Offset(0.0, -20.0));
await tester.pumpAndSettle();
const Velocity noMovement = Velocity(pixelsPerSecond: Offset(0,0));
final double afterScaling = transformationController.value.getMaxScaleOnAxis();
expect(scaleChange,greaterThan(1.0));
expect(afterScaling, isNot(equals(null)));
expect(afterScaling, isNot(equals(1.0)));
expect(currentVelocity, equals(noMovement));
expect(calledStart, equals(true));
});
testWidgets('viewport changes size', (WidgetTester tester) async {
final TransformationController transformationController = TransformationController();
await tester.pumpWidget(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment