react-native-fast-image icon indicating copy to clipboard operation
react-native-fast-image copied to clipboard

Replacing Animated.Image

Open flikQ opened this issue 9 years ago • 10 comments

Hi,

I am currently working on an animation using the standard Image tag, I would like to use FastImage for these images however Animated.FastImage obviously doesn't work.

Doesn't anyone know a way to get this working?

flikQ avatar Nov 22 '17 14:11 flikQ

const AnimatedFastImage = Animated.createAnimatedComponent(FastImage);

ahanriat avatar Nov 27 '17 15:11 ahanriat

@ahanriat I've tried this but I was not able to make it work - it shows blank (no image is shown).

<AnimatedFastImage
  style={[styles.image, { opacity: this.state.imageOpacity }, this.props.style]}
  source={{
    uri: this.props.imageSource,
    priority: FastImage.priority.normal,
  }}
  resizeMode={FastImage.resizeMode.cover}
  onLoad={() => this.onLoadImage()} //function call to Animated.timing on this.state.imageOpacity
/>

tyeon95 avatar Dec 01 '17 05:12 tyeon95

@tyeon95 Did you set height or width to your image style?

ahanriat avatar Dec 03 '17 10:12 ahanriat

There is a deeper issue with this where if the image is cached onLoad will not be called at all.

mikehuebner avatar Jan 21 '18 05:01 mikehuebner

This actually works for me with const AnimatedImage = Animated.createAnimatedComponent(FastImage);

digitaledge avatar Jan 26 '18 15:01 digitaledge

I believe all the involved issues have been resolved.

DylanVann avatar Apr 25 '18 13:04 DylanVann

It works, but when you change height and width with animation, the image is pixelated.

tarangill avatar Oct 04 '20 20:10 tarangill

in typescript u need to use like this const AnimatedFastImage: any = Animated.createAnimatedComponent( FastImage as any )

faerylay avatar May 28 '23 05:05 faerylay

in typescript u need to use like this const AnimatedFastImage: any = Animated.createAnimatedComponent( FastImage as any )

I believe we can use this for better typings

const AnimatedFastImage = Animated.createAnimatedComponent(FastImage as FC<FastImageProps>);

Correct me if I'm wrong. Thanks

ShaunLWM avatar Jan 15 '24 06:01 ShaunLWM

const AnimatedFastImage = Animated.createAnimatedComponent(FastImage);

Gave error: The signature (component: typeof FlatList, options?: Options | undefined): ComponentClass>, any> of Animated.createAnimatedComponent is deprecated.

Solved by: const AnimatedFastImage = Animated.createAnimatedComponent<FastImageProps>(FastImage as any);

saw no difference between any and FC<FastImageProps>

elmaxe avatar Feb 14 '24 10:02 elmaxe