Skip to content

High performance self-hosted photo and video management solution.

fix(mobile): skip animation for offscreen thumbnails (#21277)

Mert5405810a3849
diff --git a/mobile/lib/presentation/widgets/images/thumbnail.widget.dart b/mobile/lib/presentation/widgets/images/thumbnail.widget.dart
index f442a6ad3c..9cf77cc29e 100644
--- a/mobile/lib/presentation/widgets/images/thumbnail.widget.dart
+++ b/mobile/lib/presentation/widgets/images/thumbnail.widget.dart
@@ -125,7 +125,7 @@ class _ThumbnailState extends State<Thumbnail> with SingleTickerProviderStateMix
return;
}
- if (synchronousCall && _providerImage == null) {
+ if ((synchronousCall && _providerImage == null) || !_isVisible()) {
_fadeController.value = 1.0;
} else if (_fadeController.isAnimating) {
_fadeController.forward();
@@ -201,6 +201,15 @@ class _ThumbnailState extends State<Thumbnail> with SingleTickerProviderStateMix
_loadFromThumbhashProvider();
}
+ bool _isVisible() {
+ final renderObject = context.findRenderObject() as RenderBox?;
+ if (renderObject == null || !renderObject.attached) return false;
+
+ final topLeft = renderObject.localToGlobal(Offset.zero);
+ final bottomRight = renderObject.localToGlobal(Offset(renderObject.size.width, renderObject.size.height));
+ return topLeft.dy < context.height && bottomRight.dy > 0;
+ }
+
@override
Widget build(BuildContext context) {
final colorScheme = context.colorScheme;