Skip to content

monokee/requestPostAnimationFrame

Repository files navigation

requestPostAnimationFrame

Run tasks immediately after the browser has rendered.

Proposal: https://github.com/WICG/request-post-animation-frame/blob/main/explainer.md

Usage

import { requestPostAnimationFrame } from './request-post-animation-frame.module.js';

// Read a value from the current layout
const $el = document.getElementById('some-element');
const height = $el.clientHeight;

// Mutate the DOM inside raf
requestAnimationFrame(() => {

  $el.style.height = `${height * 2.5}px`;
  
  // To read the updated value use rPAF callback and avoid layout trashing...
  requestPostAnimationFrame(() => {
    console.log($el.clientHeight);
  });
  
});

About

Run tasks immediately after the browser has rendered: https://github.com/WICG/request-post-animation-frame/blob/main/explainer.md

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published