Open cachapa opened 3 years ago
Hi I would like to support this. On Web we definitely need mouse support please !
Any updates on this? My flutter web app is in production and embarrassing that it can't even zoom image with mouse scroll.
Flutter's ScaleUpdateDetails
should have scale
property. It should be pretty easy. When scaleUpdates.pointerCount == 0
then it's a mouse scroll.
A mouse scroll event doesn't fire any gesture recognizer because there is no pointer of contact. We should rather use pointer signal
Would be great to have this feature in the library, however here is my very basic workaround using onPointerSignal from Listener:
final _viewController = PhotoViewController();
Widget _buildPhotoView() {
return Listener(
onPointerSignal: (event) {
if (event is PointerScrollEvent) {
final delta = event.scrollDelta.dy;
final controller = _viewController;
if (controller != null) {
final scale = controller.scale ?? 1.0;
final newScale = scale - delta / 1000;
controller.scale = newScale.clamp(1.0, 10.0);
}
}
},
child: PhotoView.customChild(
child: FlutterLogo(),
enablePanAlways: true,
wantKeepAlive: true,
backgroundDecoration: const BoxDecoration(color: Colors.grey),
controller: _viewController,
),
);
}
On desktop the mouse wheel is ignored. The expected behavior would be for the image to zoom in when using the mouse wheel to scroll up and zoom out in the other direction.