Catalog npm
Back to packageRELEASE DETAILS

0.0.4

npm

4d

Performance Timing Functions for UI Development

animation timestampanimation timingcancelanimationframecanceltimeoutmozcancelanimationframemozrequestanimationframepolyfillrequestanimationframerequestanimationframe polyfillsetintervalsettimeouttiming functionswebkitcancelanimationframewebkitcancelrequestanimationframewebkitrequestanimationframe
Published23 Oct 2016
Direct dependencies24
Transitive dependenciesNot calculated

README

Current package documentation

### Performance Timing Functions for UI Development

4d

4d is a set of efficient timing functions. Click below for documentation.

Why?

  • Better performance for modern browsers and mobile devices.
  • Features a comprehensive fix for legacy compatibility issues with RAF.
  • Avoids setTimeout and setInterval unlike the majority of JavaScript timing functions.
  • Prioritise timing for browsers and mobile devices over node.
  • Limit function calls, set FPS, delay and loop to the next frame to be rendered.
  • Features a comprehensive windowResize method that resolves mobile issues.
  • Features a media queries detection API with built in custom events (Coming soon)
  • Ability to mock jittery/ random function calls e.g. emulate bad performance. (coming soon)
  • Less than 2kb gzip size (will never exceed a 4kb gzip size)

Aim

  • 4d is a tiny powerhouse, and will remain tiny.
  • 4d aims to improve common timing requirements in a clean, lightweight and modular way.
  • 4d aims to provide a better feature implementations than alternatives.

(4d === fourth dimension === t)

Compatibility

4d Is at least compatible with IE8 +

Support

  • CommonJS ...

require('4d')

  • AMD ...

define(['$4d'] , function ($4d) {...

  • ES6 ...

import {debounce, throttle, timeout } from '4d'

  • IIFE ...

src="4d.js'

Demo

  • [Most 4d functions will only work in browser environments, not Node or the Dev Tools console]

Click here to see the demo

The 4d API

cancel()

Syntax:

cancel(requestID)

Parameters:

  • requestID: The ID value returned by the call to window.requestAnimationFrame() that requested the callback.

In place of:

window.cancelAnimationFrame()

Summary:

The most comprehensive polyfill for cancelAnimationFrame. cancel() avoids mutation of the native object to prevent overriding of cancelAnimationFrame implementations that may be used within other libraries.

cancel() cancels an animation frame request previously scheduled through a call to request() or window.requestAnimationFrame().

Usage:

import { cancel } from '4d'

// id === some requestAnimationFrame ID.

cancel(id)

See more.

Browser Support:

  • Internet Explorer 5+
  • See more

Core library:

Request Frame.



request()

Syntax:

request(callback[DOMHighResTimeStamp])

Parameters:

  • callback: A parameter specifying a function to call when it's time to update your animation for the next repaint. The callback has one single argument, a DOMHighResTimeStamp, which indicates the current time (the time returned from Performance.now() ) for when requestAnimationFrame starts to fire callbacks.

In place of:

window.requestAnimationFrame(callback[DOMHighResTimeStamp])

Summary:

The most comprehensive polyfill for requestAnimationFrame. request() avoids mutation of the native object to prevent overriding of requestAnimationFrame implementations that may be used within other libraries.

request() tells the browser that you wish to perform an animation and requests that the browser call a specified function to update an animation before the next repaint. The method takes as an argument a callback to be invoked before the repaint.

Usage:

import { request } from '4d'

// Animate.
const animate = (highResTimestamp) => {
  request(animate);
  // Animate something...
}

// Start the animation on the next available frame.
request(animate);

See more.

Browser Support:

  • Internet Explorer 5+
  • See more

Core library:

Request Frame.



MIT

Copyright (c) 2016 Julien Etienne

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 24

Native requirements
24 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
request-frame
Environment
{
  "local_name": "request-frame",
  "alias": false,
  "peer_metadata": null
}
^1.5.3runtime
resizilla
Environment
{
  "local_name": "resizilla",
  "alias": false,
  "peer_metadata": null
}
^0.6.2runtime
run-once
Environment
{
  "local_name": "run-once",
  "alias": false,
  "peer_metadata": null
}
^1.0.0runtime
set-animation-frame
Environment
{
  "local_name": "set-animation-frame",
  "alias": false,
  "peer_metadata": null
}
^0.1.1runtime
set-animation-interval
Environment
{
  "local_name": "set-animation-interval",
  "alias": false,
  "peer_metadata": null
}
^0.0.2runtime
volve
Environment
{
  "local_name": "volve",
  "alias": false,
  "peer_metadata": null
}
^0.0.2runtime
babel-cli
Environment
{
  "local_name": "babel-cli",
  "alias": false,
  "peer_metadata": null
}
*development
babel-preset-es2015
Environment
{
  "local_name": "babel-preset-es2015",
  "alias": false,
  "peer_metadata": null
}
*development
babel-preset-es2015-rollup
Environment
{
  "local_name": "babel-preset-es2015-rollup",
  "alias": false,
  "peer_metadata": null
}
^1.2.0development
browserify
Environment
{
  "local_name": "browserify",
  "alias": false,
  "peer_metadata": null
}
^13.1.0development
chai
Environment
{
  "local_name": "chai",
  "alias": false,
  "peer_metadata": null
}
*development
gulp
Environment
{
  "local_name": "gulp",
  "alias": false,
  "peer_metadata": null
}
^3.9.1development
gulp-bump
Environment
{
  "local_name": "gulp-bump",
  "alias": false,
  "peer_metadata": null
}
*development
gulp-concat
Environment
{
  "local_name": "gulp-concat",
  "alias": false,
  "peer_metadata": null
}
*development
gulp-es-next
Environment
{
  "local_name": "gulp-es-next",
  "alias": false,
  "peer_metadata": null
}
*development
gulp-header
Environment
{
  "local_name": "gulp-header",
  "alias": false,
  "peer_metadata": null
}
*development
gulp-rename
Environment
{
  "local_name": "gulp-rename",
  "alias": false,
  "peer_metadata": null
}
*development
http-server
Environment
{
  "local_name": "http-server",
  "alias": false,
  "peer_metadata": null
}
*development
js-size
Environment
{
  "local_name": "js-size",
  "alias": false,
  "peer_metadata": null
}
^2.0.0development
requirejs
Environment
{
  "local_name": "requirejs",
  "alias": false,
  "peer_metadata": null
}
*development
rollup
Environment
{
  "local_name": "rollup",
  "alias": false,
  "peer_metadata": null
}
*development
rollup-plugin-babel
Environment
{
  "local_name": "rollup-plugin-babel",
  "alias": false,
  "peer_metadata": null
}
*development
rollup-plugin-node-resolve
Environment
{
  "local_name": "rollup-plugin-node-resolve",
  "alias": false,
  "peer_metadata": null
}
^2.0.0development
rollup-watch
Environment
{
  "local_name": "rollup-watch",
  "alias": false,
  "peer_metadata": null
}
*development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "d60a331b636d0f82176cdcb6cb7ddb9a39a09b70",
  "tarball": "https://registry.npmjs.org/4d/-/4d-0.0.4.tgz",
  "integrity": "sha512-y5Dso1e6nxvrhLdC1ioyADxtaUryNZhZNrtD1QD+Wtw4jz718EJZ2rAcNmBrTvYm/YJz7oSgj4HBDS9Ins2aRw==",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQCbLZVV7iCu6wZlQSFTspANQ6W9KcPoSyhDns2gch47SwIhALBWboUNdW8exS43yA+cyFJhI5wA84d++af7kjuOxQZ3"
    }
  ]
}

Repository

PENDING
envidia/request-frame

Shared repository data · GitHub

License detected in repository
Not collected

Repository

PENDING
envidia/4d

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:07 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:3395ebc1817f3f104edcc90b7bb92537abe73ae50b4bb15a54484ea641266e39

Other collected versions

0.0.55 Nov0.0.322 OctView all collected versions →