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

popmotion

Package Overview
Dependencies
Maintainers
1
Versions
312
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popmotion

The animator's toolbox

  • 11.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
decreased by-0.39%
Maintainers
1
Weekly downloads
 
Created

What is popmotion?

Popmotion is a functional, reactive JavaScript motion library that allows developers to create animations and handle gestures with ease. It provides a powerful API to animate values, handle user input, and define complex animations using simple building blocks.

What are popmotion's main functionalities?

Animation

This feature allows you to animate values from a starting point to an end point. The 'onUpdate' function is called with the latest value as the animation progresses.

import { animate } from 'popmotion';

animate({
  from: 0,
  to: 100,
  onUpdate: latest => console.log(latest)
});

Gestures

This feature handles gesture physics, such as momentum and deceleration, allowing for smooth animations that feel natural. The 'modifyTarget' function can adjust the ending value dynamically.

import { inertia } from 'popmotion';

const { stop } = inertia({
  from: 0,
  velocity: 10,
  power: 0.8,
  timeConstant: 700,
  modifyTarget: target => Math.round(target / 100) * 100,
  onComplete: () => console.log('Animation complete')
});

Pose

This feature allows you to create draggable elements that can be thrown and will return to a specified position. It combines multiple functionalities like pointer tracking and spring physics for realistic motion.

import { styler, spring, listen, pointer, value } from 'popmotion';

const ball = document.querySelector('.ball');
const divStyler = styler(ball);
const ballXY = value({ x: 0, y: 0 }, divStyler.set);

listen(ball, 'mousedown touchstart').start((e) => {
  e.preventDefault();
  pointer(ballXY.get()).start(ballXY);
});

listen(document, 'mouseup touchend').start(() => {
  spring({
    from: ballXY.get(),
    velocity: ballXY.getVelocity(),
    to: { x: 0, y: 0 },
    stiffness: 200,
    damping: 10
  }).start(ballXY);
});

Other packages similar to popmotion

Keywords

FAQs

Package last updated on 15 Aug 2022

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