最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to stop gif react-native after 1 time? - Stack Overflow

programmeradmin1浏览0评论

I have a gif in react and i want to stop the loop I add an image in my view i give to the image the path of my gif and it's work but the gif go in infinite loop

Any idea to stop ?

<Image
    source={require('./img/anim.gif')}
 />

thanks

I have a gif in react and i want to stop the loop I add an image in my view i give to the image the path of my gif and it's work but the gif go in infinite loop

Any idea to stop ?

<Image
    source={require('./img/anim.gif')}
 />

thanks

Share Improve this question asked May 2, 2017 at 13:02 Arthur BelhandouzArthur Belhandouz 1611 gold badge2 silver badges12 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Edit react-native/Libraries/Image/RCTGIFImageDecoder.m

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
    ...
animation.repeatCount = loopCount == 0 ? 0 : loopCount; // <-- fix for single play gif from joshbedo
animation.fillMode = @"forwards"; // <-- insert this line to prevent the image disappearing after animation

And for android

update to the latest fresco version (androidmanifest.xml)

pile '.facebook.fresco:animated-base-support:1.1.0' pile '.facebook.fresco:animated-gif:1.1.0'
 pile '.facebook.fresco:animated-webp:1.1.0' 
pile '.facebook.fresco:webpsupport:1.1.0'

发布评论

评论列表(0)

  1. 暂无评论