Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
julesrx committed Dec 6, 2023
1 parent d1b2879 commit f8193e1
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,24 @@ npm i bouncing-element
## Usage

```ts
import Bouncer from 'bouncing-element'; // if installed via NPM
import { createBouncer } from 'bouncing-element';

// Create the bouncer
new Bouncer({
// querySelector (default '.bounce')
selector: '.bounce',

// frame transformers (default [])
// used to add different effects to the elements for each frame
frameTransformers: [
{
// tranform key
key: 'hue',

// initial value
initialValue: 0,

// tranform function
tranformer: (bouncingEl, value) => {
bouncingEl.element.style.color = `hsl(${value}, 100%, 50%)`;
return value == 360 ? 0 : value + 1;
}
}
]
const { start, stop } = createBouncer(elements, {
// set to true to insert the elements to the body (default: false)
insert: true,

// 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;
}
}
]
});
```

0 comments on commit f8193e1

Please sign in to comment.