Skip to content

Command registerEasing

Ryc O'Chet edited this page Feb 1, 2018 · 1 revision
- NOTE: This documentation is for Velocity v2.

Command - RegisterEasing

You can register your own easings. An easing function takes the percent complete as a decimal, the start value, the end value, and the animated property name, and then returns the final value to be used. The start and end values will be numbers. When the animation is at exactly 0 or 1 percent it is advisable to copy the start and end values directly (unless the easing itself is meant to do otherwise).

To register your own easing function that can be used within Velocity calls, you must call the "registerEasing" command with a function as below:

Velocity("registerEasing", "myCustomEasing", function(percentComplete, startValue, endValue, property) {
	return percentComplete === 0
		? startValue
        : percentComplete === 1
		    ? endValue
            : (0.5 - Math.cos(percentComplete * Math.PI) / 2) * (endValue - startValue);
});