Git Product home page Git Product logo

react-native-svg-animations's Introduction

react-native-svg-animations npm version

SVG Animations wrapper for react-native. Based on examples from this project: https://github.com/ethantran/react-native-examples

Dependencies

  • svg-path-properties
  • react-native-svg

Installation

$ npm i react-native-svg-animations --save

Demo

AnimatedSVGPath AnimatedSVGPaths

Usage

This package contains wrapper components for displaying animated SVG in react-native, currently, this contains the following:

  • AnimatedSVGPath
  • AnimatedSVGPaths
AnimatedSVGPath

Component to display a single animated SVG Path. See Hi example for the complete implementation.

import { AnimatedSVGPath } from "react-native-svg-animations";

...

<View>
  <AnimatedSVGPath
    strokeColor={"green"}
    duration={500}
    strokeWidth={10}
    strokeDashArray={[42.76482137044271, 42.76482137044271]}
    height={400}
    width={400}
    scale={0.75}
    delay={100}
    d={d}
    loop={false}
  />
</View>

where the properties are:

  • d - the SVG Path to be animated. (required)
  • strokeColor - the color of the path stroke. (defaults to black)
  • strokeWidth - the thickness of the path stroke. (defaults to 1)
  • strokeDashArray - the number and length of strokes. (defaults to total length obtained from properties of d)
  • height - the height of the base SVG. (defaults to screen viewport height)
  • width - the width of the base SVG. (defaults to screen viewport width)
  • scale - the scale of the output SVG based on the width and height of the base SVG. (defaults to 1.0 or 100%)
  • delay - time in ms before starting animation. (defaults to 1000ms or 1s)
  • duration - time in ms to complete the path drawing from starting point to ending point. (defaults to 1000ms or 1s)
  • fill - the color fill of the closed path. (defaults to none)
  • loop - whether the animation loops infinitely. (defaults to true)
  • reverse - Begins drawn and fades as you go . (defaults to false)
  • rewind - the path is rewinded when it was complete. (defaults to false)
AnimatedSVGPaths

Component to display a multiple animated SVG Paths. See Ingenuity preloader example for the complete implementation.

import { AnimatedSVGPaths } from "react-native-svg-animations";

...

<View>
  <AnimatedSVGPaths
    strokeColor={"red"}
    strokeWidth={5}
    duration={10000}
    height={600}
    width={600}
    scale={0.5}
    delay={100}
    ds={ds}
  />
</View>

where the properties are:

  • ds - the SVG Paths to be animated, must be an array. (required)
  • strokeColor - the color of the path stroke. (defaults to black)
  • strokeWidth - the thickness of the path stroke. (defaults to 1)
  • height - the height of the base SVG. (defaults to screen viewport height)
  • width - the width of the base SVG. (defaults to screen viewport width)
  • scale - the scale of the output SVG based on the width and height of the base SVG. (defaults to 1.0 or 100%)
  • delay - time in ms before starting animation. (defaults to 1000ms or 1s)
  • duration - time in ms to complete the path drawing from starting point to ending point. (defaults to 1000ms or 1s)
  • fill - the color fill of the closed path. (defaults to none)
  • loop - whether the animation loops infinitely. (defaults to true)
  • reverse - Begins drawn and fades as you go . (defaults to false)
  • rewind - the path is rewinded when it was complete. (defaults to false)

TODO

  • Accept paths as objects to handle different delays and duration for each of the single path, as well as custom path properties.
  • Other animated SVG objects.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Contributors

Special thanks to these developers:

License

MIT

react-native-svg-animations's People

Contributors

73r3wy avatar jeremy-ingenuity avatar hovlev avatar animeshhestabit avatar doodlez79 avatar tristantouchain avatar dimofte avatar jvt avatar b8ne avatar kuldeepsingh93 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.