Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lottie-scale

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lottie-scale

Fast and simple JS package to scale SVG Lottie animations

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Lottie Scale

Lottie Scale is a very small NPM package to allow those with very little and out-of-scale SVG animations exported from Bodymovin to scale them, just by providing the container element and the scale multiplier.

It's particularly simple, that is, a single function call.

How to use

There are two possible ways to use Lottie Scale.

Head <script> tag

<script type="text/javascript" src="https://unpkg.com/lottie-scale@latest/dist/index.min.js"></script>
<!-- OR -->
<script type="text/javascript" src="https://unpkg.com/lottie-scale@latest/dist/index.js"></script>

Module import (ES6 import)

import * as lottieScale from 'lottie-scale'

Scale SVG animation

Lottie Scale can only do its magic after the DOM of the SVG animation is rendered so it's essential to add an event listener to the animation.

For now, the only function of the package is lottieScale:

lottieScale(zoomMultiplier int, lottieObject obj)

Usage example in a real case scenario:

// If you're using ES6 import
import * as lottieScale from 'lottie-scale'

let el = document.querySelector('#svgContainer')

const anim = lottie.loadAnimation({
  container: el,
  renderer: 'svg',
  loop: true,
  autoplay: true,
  path: 'data.json', // Dataset or any other source can be used here to provide Lottie with JSON for the animation to render
  rendererSettings: {
    scaleMode: 'cover',
  }
})

let svgRendered = el.querySelector('svg')

anim.addEventListener('DOMContentLoaded', () => {
  lottieScale(2, svgRendered)
})

In this example, the SVG animation is basically zoomed 200%.

Contributing

Feel free to add your 2 cents via the issues or pull requests tabs.

Keywords

FAQs

Package last updated on 09 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc