Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
RequestAnimationFrame event
A "request animation frame event" is similar to using Throttle
with a limit of 16
, as this event type
incorporates the browser's RequestAnimationFrame API (rAF) which aims to run at 60 fps () but
decides internally the best timing to schedule the rendering.
The best suited use-case for this event type is on "paint jobs", e.g. calculating the size of an element or move elements around.
Important
Due to the behavior of rAF, any event listener is not executed if the browser's tab is not active.
To construct the event listener, the module TYPO3/
must be imported.
The constructor accepts the following arguments:
event
(string) - the event to listen onName callback
(function) - the executed event listener when the event is triggered
const el = document.querySelector('.item');
new RequestAnimationFrameEvent('scroll', function () {
el.target.style.width = window.scrollY + 100 + 'px';
}).bindTo(window);