mirror of
https://github.com/immich-app/immich.git
synced 2025-11-01 11:07:11 -04:00
fix(mobile): skip animation for offscreen thumbnails (#21277)
This commit is contained in:
parent
e67265cef2
commit
5405810a38
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user