Neverending Pile of Messages

    request-animation-runner
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.1 • Public • Published

    request-animation-runner

    npm npm bundle size

    Class for run loop animation with RAF

    Install

    npm

    npm install request-animation-runner

    yarn

    yarn add request-animation-runner

    Usage

    import RequestAnimation from 'request-animation-runner';
    
    const requestAnimation = new RequestAnimation();
    
    requestAnimation.activate();
    requestAnimation.run(() => {
      // some logic
    });

    API

    requestAnimation.deactivate()

    Disable call requests.

    requestAnimation.deactivate();
    requestAnimation.run(() => {
      // some logic
    }); // no effect
    
    requestAnimation.activate();
    requestAnimation.run(() => {
      // some logic
    }); // handler is called

    requestAnimation.activate()

    Enable call requests.

    requestAnimation.deactivate();
    requestAnimation.run(() => {
      // some logic
    }); // no effect
    
    requestAnimation.activate();
    requestAnimation.run(() => {
      // some logic
    }); // handler is called

    requestAnimation.run

    Resolve the animation loop calculates time elapsed since the last loop and only draws if your specified fps interval is achieved.

    • @param {function} animationFunc - Function for animation

    • @param {string} fps - Frames per Second

    • @returns {undefined}

    requestAnimation.run(() => {
      // some logic
    });

    requestAnimation.request

    Request single call.

    • @param {function} animationFunc - Function for animation

    • @returns {undefined}

    requestAnimation.request(() => {
      // some logic
    });

    requestAnimation.cancelRequest

    Cancel current request.

    • @returns {undefined}
    requestAnimation.cancelRequest();

    Run tests

    npm test

    Maintainer

    Krivega Dmitriy

    Contributing

    Contributions, issues and feature requests are welcome!
    Feel free to check issues page. You can also take a look at the contributing guide.

    📝 License

    Copyright © 2020 Krivega Dmitriy.
    This project is MIT licensed.

    Keywords

    Install

    npm i request-animation-runner

    DownloadsWeekly Downloads

    15

    Version

    0.3.1

    License

    MIT

    Unpacked Size

    48.6 kB

    Total Files

    20

    Last publish

    Collaborators

    • krivega