interface ScrollProgress { _handleUpdate : ( x : number , y : number ) => void ; _viewportHeight : number ; _viewportWidth : number ; _getViewportHeight : ( ) => number ; _getViewportWidth : ( ) => number ; _progress : Coordinates ; _getProgress : ( ) => Coordinates ; _onScroll : ( ) => void ; _onResize : ( ) => void ; trigger : ( ) => void ; destroy : ( ) => void ; } type Coordinates = { x : number ; y : number ; } ; method returns { undefined } function noop ( ) { } constructor param { Function } handleUpdate returns { undefined } const ScrollProgress = ( function ( this , handleUpdate ) : void { this . _handleUpdate = typeof handleUpdate === 'function' ? handleUpdate : noop ; this . _viewportHeight = this . _getViewportHeight ( ) ; this . _viewportWidth = this . _getViewportWidth ( ) ; this . _progress = this . _getProgress ( ) ; this . _handleUpdate ( this . _progress . x , this . _progress . y ) ; this . _onScroll = this . _onScroll . bind ( this ) ; this . _onResize = this . _onResize . bind ( this ) ; window . addEventListener ( 'scroll' , this . _onScroll ) ; window . addEventListener ( 'resize' , this . _onResize ) ; } as any ) as { new ( handleUpdate ) : ScrollProgress ; } ; method returns { Number } ScrollProgress . prototype . _getViewportHeight = function ( ) : number { return document . body . scrollHeight - window . innerHeight ; } ; method returns { Number } ScrollProgress . prototype . _getViewportWidth = function ( ) : number { return document . body . scrollWidth - window . innerWidth ; } ; method returns { Object } ScrollProgress . prototype . _getProgress = function ( ) : Coordinates { const x = typeof window . scrollX === 'undefined' ? window . pageXOffset : window . scrollX ; const y = typeof window . scrollY === 'undefined' ? window . pageYOffset : window . scrollY ; return { x : this . _viewportWidth === 0 ? 0 : x / this . _viewportWidth , y : this . _viewportHeight === 0 ? 0 : y / this . _viewportHeight } ; } ; method returns { undefined } ScrollProgress . prototype . _onScroll = function ( ) : void { this . _progress = this . _getProgress ( ) ; this . _handleUpdate ( this . _progress . x , this . _progress . y ) ; } ; method returns { undefined } ScrollProgress . prototype . _onResize = function ( ) : void { this . _viewportHeight = this . _getViewportHeight ( ) ; this . _viewportWidth = this . _getViewportWidth ( ) ; this . _progress = this . _getProgress ( ) ; this . _handleUpdate ( this . _progress . x , this . _progress . y ) ; } ; method returns { undefined } ScrollProgress . prototype . trigger = function ( ) : void { this . _handleUpdate ( this . _progress . x , this . _progress . y ) ; } ; method returns { undefined } ScrollProgress . prototype . destroy = function ( ) : void { window . removeEventListener ( 'scroll' , this . _onScroll ) ; window . removeEventListener ( 'resize' , this . _onResize ) ; this . _handleUpdate = null ; } ; export default ScrollProgress ;