export class BackToTop { static toggleBackButton ( btnElement , show ) { btnElement . classList . toggle ( 'show' , show ) ; } static handleBackButton ( container ) { container . scrollTop = 0 ; } static makeBackButton ( d ) { const _div = d . createElement ( 'div' ) ; _div . classList . add ( 'back-to-top' ) ; _div . innerHTML = `<div class="back-to-top-container"><span>Back</span></div>` ; return _div ; } constructor ( ) { this . init ( ) ; } private init ( ) { const container = document . querySelector ( '#container-position' ) ; const main = document . querySelector ( '.main' ) ; const backButton = BackToTop . makeBackButton ( document ) ; main . appendChild ( backButton ) ; backButton . addEventListener ( 'click' , ( ) => { BackToTop . handleBackButton ( container ) ; } ) ; container . addEventListener ( 'scroll' , ( e ) => { BackToTop . toggleBackButton ( backButton , ( < Element > e . target ) . scrollTop > 300 ) ; } ) ; } }