mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-12-02 18:06:21 +00:00
24 lines
643 B
JavaScript
24 lines
643 B
JavaScript
/**
|
|
* Create an observer for showing/hiding feature and for firing scroll event hooks.
|
|
*
|
|
* @param {Function} onResize functionality for when the element during resize
|
|
* @param {Function} onResizeEnd functionality for when the element at the end of resize
|
|
* @return {ResizeObserver}
|
|
*/
|
|
function initResizeObserver( onResize, onResizeEnd ) {
|
|
/* eslint-disable-next-line compat/compat */
|
|
return new ResizeObserver( () => {
|
|
onResize();
|
|
if ( onResizeEnd ) {
|
|
clearTimeout( window.resizedFinished );
|
|
window.resizedFinished = setTimeout( () => {
|
|
onResizeEnd();
|
|
}, 250 );
|
|
}
|
|
} );
|
|
}
|
|
|
|
module.exports = {
|
|
initResizeObserver
|
|
};
|