Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

raf

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raf

requestAnimationFrame polyfill for node and the browser

  • 3.3.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is raf?

The raf npm package provides a simple and efficient way to use requestAnimationFrame in web browsers, with polyfills for unsupported environments. It's primarily used for creating smooth animations and handling frame-based updates in web applications.

What are raf's main functionalities?

Basic Animation Loop

This demonstrates how to create a basic animation loop using raf. The `raf` function is called with a callback function (`tick`), which will be executed before the next repaint. The `tick` function then calls `raf` with itself to continue the loop.

var raf = require('raf');
raf(function tick() {
  // Animation or frame update logic here
  raf(tick);
});

Canceling an Animation Frame

This example shows how to schedule an animation frame and then cancel it. The `raf` function returns a handle that can be used with `raf.cancel` to prevent the scheduled callback from executing.

var raf = require('raf');
var handle = raf(function() {
  // Animation or frame update logic here
});
// Cancel the scheduled frame update
raf.cancel(handle);

Other packages similar to raf

Keywords

FAQs

Package last updated on 16 Aug 2016

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc