easeInterval

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.function

This function allows you to call a callback function exactly as the setInterval would do but with an easing that you can specify, as well as an interval setting to customize how many time your function will be called. By default this function will pass the “easedPercent” that represent the percentage of your passed “duration” with the easing applied on it. With that you can make everything you want inside your callback function.

Params

  1. duration*-Number

    The duration of your interval process you want

  2. cbnullFunction

    A callback function to call at each interval

  3. settings{}TEaseIntervalSettings

    Some settings to customize your interval process

Return

  1. -Promise<number>

    A promise that will be resolved once the process is complete

Example

import { easeInterval } from '@blackbyte/sugar/function';
await easeInterval(2000, (easedPercent) => {
     // do something...
}, {
     interval: 1000 / 25 // 25 times by second
});

Settings

  1. inteval1000/25Number

    An interval in ms to call your callback function

  2. easingeaseInOutQuartFunction

    An easing function that take as parameter a value between 0 and 1

  3. from0Number

    The value to start with

  4. to100Number

    The value to end with

Author