New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@ultraq/transition

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ultraq/transition

DIY transitions in JavaScript

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Transition

npm License

DIY transitions in JavaScript.

Installation

npm install @ultraq/transition --save

Usage

import Transition from '@ultraq/transition';

let transition = new Transition(delta => {
  window.scrollTo(0, delta * 1000);
}, 500, BezierEasing(0.25, 0.1, 0.25, 1.0));
transition.start().then(() => {
  console.log('Done!');
});

The Transition constructor takes 3 parameters:

  • callback: A function that is called at every possible frame with a single parameter, a "delta" value between 0.0 and 1.0 to convey at what point the current frame through the transition is up to, based on the duration and the timing function.
  • duration: How long, in milliseconds, the transition should run for.
  • timingFunction: optional, the easing function used to calculate the delta passed to the transition function. Defaults to a linear function if not specified.

The default timing function is provided by the bezier-easing library, and so any other curves created by this library are guaranteed to work, but any library that can define a bezier curve and, given some X value can return Y on the curve, will suffice.

To kick off the transition, call the start method on the transition instance. This will return a Promise that is resolved once the transition duration has elapsed.

Keywords

javascript

FAQs

Package last updated on 05 Apr 2018

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