项目作者: danijelgrabez

项目描述 :
Animated lazy loading image component for React Native
高级语言: JavaScript
项目地址: git://github.com/danijelgrabez/lazy-image.git
创建时间: 2019-02-28T10:04:42Z
项目社区:https://github.com/danijelgrabez/lazy-image

开源协议:MIT License

下载


Example usage of LazyImage component

Lazy Image

React Native image component with animated lazy loading.
Demo 👉@danijelgrabez/bGF6eS">Expo Snack.

Install

npm i animated-lazy-image -S

or,

yarn add animated-lazy-image

Usage

Props:

  1. source - Image source
  2. placeholderColor - Placeholder background color, if it is not provided, it will fallback to #e3e3e3
  3. customPlaceholder - Custom placeholder component
  1. import LazyImage from 'animated-lazy-image';
  2. /**
  3. * Base example
  4. */
  5. <LazyImage
  6. source="https://images.unsplash.com/photo-1551148552-c19ee5b0c116?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2733&q=80"
  7. ></LazyImage>
  8. /**
  9. * With custom placeholder background color
  10. */
  11. <LazyImage
  12. source="https://images.unsplash.com/photo-1551148552-c19ee5b0c116?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2733&q=80"
  13. placeholderColor="#f74b59"
  14. ></LazyImage>
  15. /**
  16. * With custom placeholder component
  17. */
  18. <LazyImage
  19. source="https://images.unsplash.com/photo-1551148552-c19ee5b0c116?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2733&q=80"
  20. customPlaceholder={<CustomComponent ></LazyImage>}
  21. />

TODO

  • Provide tests
  • Improve loading performance (trigger image load when it arrives in the viewport)

Suggestions?

Shoot me an email, or submit an issue 🚀