Skip to content

reemardelarosa/polymate

Repository files navigation

Polymate - Lottie Animation View for Polymer 2

Published on webcomponents.org GitHub issues GitHub stars GitHub license

wrapper of lottie-web

Lottie is a mobile library for Web, and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. They say a picture is worth 1,000 words so here are 13,000:

Example2 Example1 Example3 Example4

Why Lottie?

Flexible After Effects features

We currently support solids, shape layers, masks, alpha mattes, trim paths, and dash patterns. And we’ll be adding new features on a regular basis.

Manipulate your animation any way you like

You can go forward, backward, and most importantly you can program your animation to respond to any interaction.

Small file sizes

Bundle vector animations within your app without having to worry about multiple dimensions or large file sizes. Alternatively, you can decouple animation files from your app’s code entirely by loading them from a JSON API.

Download lottie files › lottiefiles.com

View documentation, FAQ, help, examples, and more at airbnb.io/lottie

<style> 
  #polymateElement {
     --polymate-view-width: 400px;
  }
</style>
<polymate-view id="polymateElement" path="demo/motorcycle.json" autoplay loop show-controllers></polymate-view>

Installation

Install through npm:

npm install --save polymate

Install through bower:

bower install --save polymate

Usage

  1. Import the polymate view component
<link rel="import" href="../polymate/polymate-view.html">
  1. Initialize

Download animation json from LottieFiles.com or use some json from demo folder

  • Using path, autoplay and loop
<polymate-view id="polymateElement" path="data.json" autoplay loop></polymate-view>
  • Using options object
<polymate-view id="polymateElement"></polymate-view>

<script>
    class PolymateElement extends Polymer.Element {
      static get is() { return 'polymate-element'; }

      ready() {
        super.ready();

        this.$.polymateElement.options = {
          path: 'data.json',
          loop: true,
          autoplay: true
        };
      }
    }
  
  window.customElements.define(PolymateElement.is, PolymateElement);
</script>
  1. Style
  • custom vars
<style> 
  #polymateElement {
     --polymate-view-width: 100px;
     --polymate-view-height: 100px;
  }
</style>
  • font-size
<style>
  #polymateElement {
     font-size: 24px;
  }
</style>

Configuration

You can pass a configuration object through options property:

  • animationData: an Object with the exported animation data.
  • path: the relative path to the animation object. (animationData and path are mutually exclusive)
  • loop: true / false / number
  • autoplay: true / false it will start playing as soon as it is ready
  • renderer: 'svg' / 'canvas' / 'html' to set the renderer

More information on lottie-web Documentation

Related Projects

Contribution

Appreciate your contributions and suggestions.

License

MIT