Socket
Book a DemoInstallSign in
Socket

jframes

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jframes

A light weight javascript animation frame library

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

jframes

Build Status NPM version

A light weight animation frame support. With the frame object, you are convinent to do some calculation.

The Frame Object

The frame object will pass in the jframes.request() callback. It providers:

  • frame.time time in javascript (eg. +new Date()).
  • frame.index index of the requested frame sequence base on zero.
  • frame.dur the duration time from current frame to the last frame in ms.
  • frame.elapsed the elapsed time from the first frame to current frame in ms.
  • frame.next() tells jframes to execute the next frame, if this method are not called, the animation stops.

Usage

If you want to request a frame, just call jframes.request()

var req = jframes.request(function(frame) {
  console.log('avg frame rate: ' + frame.elapsed / (frame.index + 1));
  
  // render stuff
  
  frame.next(); // call the next frame
});

// jframes.release(req); // release resources

The function pass to jframes.request() will generate a frame sequence correspond to the function. The function will be the action of the frame sequence.

We keep track of frame informations for every frame sequence. You can use jframes.request() multi times without worry of calculation. For example:

jframes.request(function(frame) {
  if (frame.index < 5) {
    console.log('frame seq 1: frame %d executed!', frame.index);
    frame.next();
  }
});

jframes.request(function(frame) {
  if (frame.index < 10) {
    console.log('frame seq 2: frame %d executed!', frame.index);
    frame.next();
  }
});

Keywords

animation

FAQs

Package last updated on 15 Apr 2015

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.