Skip to content

Latest commit

 

History

History

nano-spring

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@bluecateng/nano-spring GitHub license npm version

Tiny implementation of spring animation with mass set to 1.

Size: 290 bytes before compression.

Installation

npm i -S @bluecateng/nano-spring

Example

import spring from '@bluecateng/nano-spring';

const element = document.querySelector('#test');
element.style.opacity = 0.5;
spring(
	250,
	30,
	(p) => (element.style.transform = `translateX(${p * 300}px)`),
	() => (element.style.opacity = '')
);

Output

Output