React-native ListView Loading a picture fade effect component

Source: Internet
Author: User

In today's practice project, you need to add a fade effect to the ListView when loading the picture, so you simply encapsulate a component yourself:

1' Use strict '2 3Import React from ' react-native '4 5 var {6 Animated,7 Proptypes8} =React9 Ten class Aniimage extends React.component { OneStatic Proptypes = { A url:PropTypes.string, - InputRange:PropTypes.array, - OutputRange:PropTypes.array the   }; - render () { -     var{style, URL, Inputrange, outputrange} = This. Props -      This. _animatedvalue =NewAnimated.value (0) +Let interpolatedcoloranimation = This. _animatedvalue.interpolate ({ - Inputrange:inputrange, + Outputrange:outputrange A     }) at     return ( -<Animated.image -onloadend={() = { -Animated.timing ( This. _animatedvalue, { -tovalue:100, -duration:500 in }). Start () -         }} toSource={{Uri:url}} +Style={[style, {opacity:interpolatedcoloranimation}]}/> -     ) the   } * } $ Panax NotoginsengModule.exports = Aniimage

So how do you call it?

First, import Aniimage

Second, call

1 <aniimage2  inputrange={[0, +]}3  outputrange={[0, 1 ]}4  style={styles.aniimage}5  url={' http://192.168.6.5:8888/ Getimage?imgname= ' + commidities.imgpath1}/>

This will see the desired effect.

Https://github.com/weifengzz/GuoKu

You can see my complete project on GitHub.

React-native ListView Loading a picture fade effect component

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.