bouncing-element
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Bouncing Element

npm Build

JavaScript library to reproduce the famous DVD screensaver with any DOM element.

Installation

  • Via CDN:
<script src="https://unpkg.com/bouncing-element"></script>
  • Using npm:
npm i bouncing-element

Usage

import { createBouncer } from 'bouncing-element';

// Create the bouncer
const { start, stop } = createBouncer(elements, {
    // start the animation when creating the bouncer (default: true)
    start: true,

    // set to true to insert the elements to the body (default: false)
    insert: false,

    // distance in pixels to the screen borders (default: 50)
    startOffset: false,

    // frame transformers (default: [])
    // used to add different effects to the elements for each frame
    frameTransformers: [
        {
            key: 'hue',
            initialValue: 0,
            tranformer: (el, value) => {
                el.element.style.color = `hsl(${value}, 100%, 50%)`;
                return value == 360 ? 0 : value + 1;
            }
        }
    ]
});

Readme

Keywords

Package Sidebar

Install

npm i bouncing-element

Weekly Downloads

16

Version

2.0.1

License

none

Unpacked Size

7.47 kB

Total Files

7

Last publish

Collaborators

  • julesrx