method memberof argument { Element } element argument { String } top returns { number } export function getScroll ( target , top ? ) { if ( typeof window === 'undefined' ) { return 0 ; } const prop = top ? 'pageYOffset' : 'pageXOffset' ; const method = top ? 'scrollTop' : 'scrollLeft' ; const isWindow = target === window ; let ret = isWindow ? ( target as Window ) [ prop ] : ( target as HTMLElement ) [ method ] ; if ( isWindow && typeof ret !== 'number' ) { ret = document . documentElement [ method ] ; } return ret ; }