license import { MDCTopAppBarAdapter } from '../adapter' ; import { cssClasses } from '../constants' ; import { MDCTopAppBarBaseFoundation } from '../foundation' ; export class MDCShortTopAppBarFoundation extends MDCTopAppBarBaseFoundation { get isCollapsed ( ) : boolean { return this . collapsed ; } private collapsed = false ; private isAlwaysCollapsed = false ; constructor ( adapter ? ) { super ( adapter ) ; } override init ( ) { super . init ( ) ; if ( this . adapter . getTotalActionItems ( ) > 0 ) { this . adapter . addClass ( cssClasses . SHORT_HAS_ACTION_ITEM_CLASS ) ; } this . setAlwaysCollapsed ( this . adapter . hasClass ( cssClasses . SHORT_COLLAPSED_CLASS ) ) ; } param value setAlwaysCollapsed ( value ) { this . isAlwaysCollapsed = ! ! value ; if ( this . isAlwaysCollapsed ) { this . collapse ( ) ; } else { this . maybeCollapseBar ( ) ; } } getAlwaysCollapsed ( ) { return this . isAlwaysCollapsed ; } /**
     * Scroll handler for applying/removing the collapsed modifier class on the short top app bar.
     */ override handleTargetScroll ( ) { this . maybeCollapseBar ( ) ; } private maybeCollapseBar ( ) { if ( this . isAlwaysCollapsed ) { return ; } const currentScroll = this . adapter . getViewportScrollY ( ) ; if ( currentScroll <= 0 ) { if ( this . collapsed ) { this . uncollapse ( ) ; } } else { if ( ! this . collapsed ) { this . collapse ( ) ; } } } private uncollapse ( ) { this . adapter . removeClass ( cssClasses . SHORT_COLLAPSED_CLASS ) ; this . collapsed = false ; } private collapse ( ) { this . adapter . addClass ( cssClasses . SHORT_COLLAPSED_CLASS ) ; this . collapsed = true ; } } export default MDCShortTopAppBarFoundation ;