import { isFunction } from '@utils/lang' ; import debounce from 'lodash/debounce' ; export const removeClass = ( element , className ) => { if ( ! element ) return ; if ( isFunction ( element . classList . remove ) ) { element . classList . remove ( className ) ; } else { element . className = element . className . split ( ' ' ) . filter ( name => name !== className ) . join ( ' ' ) ; } } ; export const addClass = ( element , className ) => { if ( ! element ) return ; if ( isFunction ( element . classList . add ) ) { element . classList . add ( className ) ; } else { element . className = [ element . className , className ] . join ( ' ' ) ; } } ; see https export const setWindowCustomProperties = ( ) => { const setViewportHeight = ( ) => { const vh = window . innerHeight * 0.01 ; const vw = window . innerWidth * 0.01 ; document . documentElement . style . setProperty ( '--vh' , `${ vh }px` ) ; document . documentElement . style . setProperty ( '--vw' , `${ vw }px` ) ; } ; setViewportHeight ( ) ; const setViewportHeightOnResize = debounce ( setViewportHeight , 200 ) ; window . addEventListener ( 'resize' , setViewportHeightOnResize ) ; return ( ) => { window . removeEventListener ( 'resize' , setViewportHeightOnResize ) ; } ; } ;