Socket
Socket
Sign inDemoInstall

nanoraf

Package Overview
Dependencies
1
Maintainers
26
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nanoraf

Only call RAF when needed


Version published
Maintainers
26
Install size
10.3 kB
Created

Readme

Source

nanoraf stability

npm version build status test coverage downloads js-standard-style

Only call RAF when needed.

Usage

var nanoraf = require('nanoraf')
var prev = null

var frame = nanoraf(function render (state) {
  console.log(state.now)
})

updateState({ now: date.now() })
updateState({ now: date.now() })
updateState({ now: date.now() })
updateState({ now: date.now() })

function updateState (state) {
  prev = prev || {}
  frame(state, prev)
  prev = state
}

API

frame = nanoraf(render, raf?)

Wrap a render function that is called on every raf tick. If no new state is available, it will not tick. Passes the last version of the state on every tick.

Optionally, provide an implementation of requestAnimationFrame via the raf parameter (for example, the one provided by the raf package). If omitted, raf defaults to window.requestAnimationFrame.

frame([arguments])

Pass arguments into the render function, to be called on a new tick.

Installation

$ npm install nanoraf

License

MIT

Keywords

FAQs

Last updated on 17 Jul 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc