New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: why is Image#fadeDuration not an opt-in feature so it's consistent with iOS? #10194
Comments
Thanks for bringing this up! I suspect this is to make things feel more native, to act like the underlying platform does. At this point making it opt-in would be a breaking change and I don't think that is worth it. |
Would be nice to have this feature opt-out. I managed to prevent the fade animation by wrapping my Something like this: public class NoFadeImageWrapper extends ViewGroup {
public NoFadeImageWrapper(Context context) {
super(context);
}
@Override
public void onViewAdded(View child) {
if (child instanceof ReactImageView) {
((ReactImageView) child).setFadeDuration(0);
ReflectionUtils.setField(child, "mIsDirty", true);
((ReactImageView) child).maybeUpdateView();
}
super.onViewAdded(child);
}
}
public class ReflectionUtils {
public static void setField(Object obj, String name, Object value) {
try {
Field field = getField(obj.getClass(), name);
if (field == null) {
return;
}
field.setAccessible(true);
field.set(obj, value);
} catch (Exception e) {
e.printStackTrace();
}
}
} |
|
@DylanVann yeah, it's possible to override fadeDuration, but in this issue I was just asking why the default is 300ms where I think it should be 0ms if we ever want iOS and Android to be consistent. |
@DylanVann Thanks a lot! Obviously that was a hack since I wasn't aware of fadeDuration |
It's generally better to match platform standards rather than try to be pixel identical, so this is how we try to make the defaults. But of course you should also pay close attention to the design on both platforms and dial them in the way you want. For high quality multi-platform apps, only about 85-90% of code is shared, and the remaining 10-15% is needed to make the app conform to platform specifics. |
When porting an app to Android, you notice images starts to weirdly fade in when they appear, it might not work properly if you manage yourself the "degraded loading" of images and stuff like that.
I'm wondering why this fadeDuration has been conceived to be opt-out to disable. React Native have an hardcoded default value of 300ms that you can't even override.. (what if I want to disable it completely, I can't).
Why is fadeDuration not opt-in, so you explicitely enable it? It would be consistent with Image.ios and eventually we could image iOS to support this prop too.
The text was updated successfully, but these errors were encountered: