Code Monkey home page Code Monkey logo

runloop's Introduction

RunLoop

Run loop is a light wrapper around the requestAnimationFrame API. The run loop is just as it sounds, a run loop. It follows a dynamic timing pattern, with an update and render function callback structure. Objects may subscribe to its callback by calling addCall, and passing a callback and the appropriate callback mask.

Callback mask types available:

  • RunLoop.UPDATE_CYCLE
  • RunLoop.RENDER_CYCLE

Update calls receive an elapsed time in milliseconds, where the render calls will not.

The order for each loop goes update then render. The elapsed time is only provided to the update call.

requestAnimFrame Polyfill

requestAnimFrame is a polyfill to support requestAnimationFrame and cancelAnimationFrame across browser. This uses an internally provided performance.now(). If this polyfill is used, performanceNow polyfill does not need to be included, it is already included. Since cancelAnimationFrame was widely unsupported while the requestAnimationFrame was used, a noop will be provided in the event that a cancelAnimationFrame does not exist.

Polyfills the following methods, and allows access via UMD, and appends it to the global space, if necessary:

  • requestAnimFrame
  • cancelAnimFrame
  • performance

performance.now() Polyfill

performance.now() uses the native Web Timing API, but if it is not supported, it uses Date patterns to polyfill. This includes a timing.navigationStart property. The polyfill does not include any of the events or other features beyond the now() functionality, and will not provide microsecond level resolution when the native API isn't available.

runloop's People

Contributors

adamrenny avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.