ngx-foldable
Version:
Angular library to help you build dual-screen experiences for foldable or dual-screen devices
60 lines (59 loc) • 2.6 kB
TypeScript
import { OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
import { ScreenContext } from './screen-context';
import * as i0 from "@angular/core";
/** Spanning mode conditions for use with {@link IfSpanDirective}. */
export declare type SpanCondition = 'dual-horizontal' | 'dual-vertical' | 'none' | 'multi';
/**
* Enumeration of spanning mode conditions values for use with
* {@link IfSpanDirective}.
*/
export declare const SpanCondition: {
/** Screen spanning mode is dual horizontal viewports. */
Vertical: SpanCondition;
/** Screen spanning mode is dual vertical viewports. */
Horizontal: SpanCondition;
/** No screen spanning (single screen mode). */
None: SpanCondition;
/** Any screen spanning mode is active (multi screen mode). */
Multi: SpanCondition;
};
/**
* Shows template only if the current screen spanning mode matches
* specified {@link SpanCondition}.
*
* Behaves like `ngIf`, except that it accepts a {@link SpanCondition} instead of
* a boolean expression.
*
* @example
* <p *fdIdSpan="'multi'">This text will only be visible on multi screen devices.</p>
* @example
* <p *fdIdSpan="'none'; else alt">This text will only be visible on single screen devices.</p>
* <ng-template #alt">This text will only be visible on multi screen devices.</ng-template>
*/
export declare class IfSpanDirective<T> implements OnDestroy {
private screenContext;
private viewContainer;
private screenContextSubscription;
private condition;
private thenTemplateRef;
private elseTemplateRef;
private thenViewRef;
private elseViewRef;
/**
* The spanning mode condition that defines if the template should be shown.
*
* @param condition The spanning mode condition for showing the template.
*/
set fdIfSpan(condition: SpanCondition);
/** A template to show if the span condition evaluates to true. */
set fdIfSpanThen(templateRef: TemplateRef<T> | null);
/** A template to show if the span condition evaluates to false. */
set fdIfSpanElse(templateRef: TemplateRef<T> | null);
constructor(screenContext: ScreenContext, viewContainer: ViewContainerRef, templateRef: TemplateRef<T>);
/** ignore */
ngOnDestroy(): void;
private matchCondition;
private updateView;
static ɵfac: i0.ɵɵFactoryDeclaration<IfSpanDirective<any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<IfSpanDirective<any>, "[fdIfSpan]", never, { "fdIfSpan": "fdIfSpan"; "fdIfSpanThen": "fdIfSpanThen"; "fdIfSpanElse": "fdIfSpanElse"; }, {}, never, never, false, never>;
}