Showing
1 changed file
with
20 additions
and
17 deletions
@@ -245,7 +245,7 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom> | @@ -245,7 +245,7 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom> | ||
245 | preview = index; | 245 | preview = index; |
246 | transformationController.value.setIdentity(); | 246 | transformationController.value.setIdentity(); |
247 | if (kIsWeb) { | 247 | if (kIsWeb) { |
248 | - _mouseCursor = SystemMouseCursors.grab; | 248 | + _updateCursor(SystemMouseCursors.grab); |
249 | } | 249 | } |
250 | }); | 250 | }); |
251 | _zoomChanged(); | 251 | _zoomChanged(); |
@@ -285,32 +285,24 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom> | @@ -285,32 +285,24 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom> | ||
285 | 285 | ||
286 | Widget _zoomPreview() { | 286 | Widget _zoomPreview() { |
287 | final zoomPreview = GestureDetector( | 287 | final zoomPreview = GestureDetector( |
288 | - onTapDown: kIsWeb | ||
289 | - ? (_) { | ||
290 | - setState(() { | ||
291 | - _mouseCursor = SystemMouseCursors.grabbing; | ||
292 | - }); | ||
293 | - } | ||
294 | - : null, | ||
295 | - onTapUp: kIsWeb | ||
296 | - ? (_) { | ||
297 | - setState(() { | ||
298 | - _mouseCursor = SystemMouseCursors.grab; | ||
299 | - }); | ||
300 | - } | ||
301 | - : null, | ||
302 | onDoubleTap: () { | 288 | onDoubleTap: () { |
303 | setState(() { | 289 | setState(() { |
304 | preview = null; | 290 | preview = null; |
305 | if (kIsWeb) { | 291 | if (kIsWeb) { |
306 | - _mouseCursor = MouseCursor.defer; | 292 | + _updateCursor(MouseCursor.defer); |
307 | } | 293 | } |
308 | }); | 294 | }); |
309 | _zoomChanged(); | 295 | _zoomChanged(); |
310 | }, | 296 | }, |
297 | + onLongPressCancel: | ||
298 | + kIsWeb ? () => _updateCursor(SystemMouseCursors.grab) : null, | ||
299 | + onLongPressDown: | ||
300 | + kIsWeb ? (_) => _updateCursor(SystemMouseCursors.grabbing) : null, | ||
311 | child: InteractiveViewer( | 301 | child: InteractiveViewer( |
312 | transformationController: transformationController, | 302 | transformationController: transformationController, |
313 | maxScale: 5, | 303 | maxScale: 5, |
304 | + onInteractionEnd: | ||
305 | + kIsWeb ? (_) => _updateCursor(SystemMouseCursors.grab) : null, | ||
314 | child: Center( | 306 | child: Center( |
315 | child: PdfPreviewPage( | 307 | child: PdfPreviewPage( |
316 | pageData: pages[preview!], | 308 | pageData: pages[preview!], |
@@ -321,12 +313,23 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom> | @@ -321,12 +313,23 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom> | ||
321 | ), | 313 | ), |
322 | ); | 314 | ); |
323 | return kIsWeb | 315 | return kIsWeb |
324 | - ? MouseRegion(cursor: _mouseCursor, child: zoomPreview) | 316 | + ? MouseRegion( |
317 | + cursor: _mouseCursor, | ||
318 | + child: zoomPreview, | ||
319 | + ) | ||
325 | : zoomPreview; | 320 | : zoomPreview; |
326 | } | 321 | } |
327 | 322 | ||
328 | void _zoomChanged() => widget.onZoomChanged?.call(preview != null); | 323 | void _zoomChanged() => widget.onZoomChanged?.call(preview != null); |
329 | 324 | ||
325 | + void _updateCursor(MouseCursor mouseCursor) { | ||
326 | + if (mouseCursor != _mouseCursor) { | ||
327 | + setState(() { | ||
328 | + _mouseCursor = mouseCursor; | ||
329 | + }); | ||
330 | + } | ||
331 | + } | ||
332 | + | ||
330 | @override | 333 | @override |
331 | Widget build(BuildContext context) { | 334 | Widget build(BuildContext context) { |
332 | Widget page; | 335 | Widget page; |
-
Please register or login to post a comment