You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@motionone/easing

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@motionone/easing

A collection of easing functions.


Version published
Weekly downloads
1.1M
increased by2.69%
Maintainers
2
Created
Weekly downloads
 

Package description

What is @motionone/easing?

@motionone/easing is a JavaScript library that provides a collection of easing functions for animations. These functions help create smooth transitions and animations by defining the rate of change of a parameter over time.

What are @motionone/easing's main functionalities?

Basic Easing Functions

This feature provides basic easing functions like easeIn, easeOut, and easeInOut. These functions can be used to create smooth animations by adjusting the rate of change of a parameter over time.

const { easeIn, easeOut, easeInOut } = require('@motionone/easing');

// Example usage
const startValue = 0;
const endValue = 100;
const duration = 1000; // in milliseconds

function animate(time) {
  const progress = time / duration;
  const easedProgress = easeIn(progress);
  const currentValue = startValue + (endValue - startValue) * easedProgress;
  console.log(currentValue);
  if (time < duration) {
    requestAnimationFrame(animate);
  }
}

requestAnimationFrame(animate);

Custom Easing Functions

This feature allows you to create custom easing functions using cubic bezier curves. You can define your own easing curves to achieve unique animation effects.

const { cubicBezier } = require('@motionone/easing');

// Define a custom cubic bezier easing function
const customEase = cubicBezier(0.42, 0, 0.58, 1);

// Example usage
const startValue = 0;
const endValue = 100;
const duration = 1000; // in milliseconds

function animate(time) {
  const progress = time / duration;
  const easedProgress = customEase(progress);
  const currentValue = startValue + (endValue - startValue) * easedProgress;
  console.log(currentValue);
  if (time < duration) {
    requestAnimationFrame(animate);
  }
}

requestAnimationFrame(animate);

Spring Easing Functions

This feature provides spring-based easing functions, which simulate the physics of a spring. These functions can create more natural and dynamic animations.

const { spring } = require('@motionone/easing');

// Define a spring easing function
const springEase = spring({ stiffness: 100, damping: 10 });

// Example usage
const startValue = 0;
const endValue = 100;
const duration = 1000; // in milliseconds

function animate(time) {
  const progress = time / duration;
  const easedProgress = springEase(progress);
  const currentValue = startValue + (endValue - startValue) * easedProgress;
  console.log(currentValue);
  if (time < duration) {
    requestAnimationFrame(animate);
  }
}

requestAnimationFrame(animate);

Other packages similar to @motionone/easing

Readme

Source

@motionone/easing

Easing functions for Motion One.

📚 Documentation

Full docs for Motion One available at motion.dev.

FAQs

Package last updated on 09 Jan 2024

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc