@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
29 lines (28 loc) • 1.67 kB
TypeScript
import type { TypedEventTarget } from '../../../esl-event-listener/core/types';
export interface IMediaQueryCondition extends TypedEventTarget<ESLMediaChangeEvent> {
/** @returns true if current environment satisfies query */
readonly matches: boolean;
/** Subscribes to media query state change. Shortcut for `addEventListener('change', callback)` */
addEventListener(callback: EventListener): void;
/** Subscribes to media query state change. Implements {@link EventTarget} interface */
addEventListener(type: 'change', callback: EventListener): void;
/** Unsubscribes from media query state change event. Shortcut for `removeEventListener('change', callback)` */
removeEventListener(callback: EventListener): void;
/** Unsubscribes from media query state change event. Implements {@link EventTarget} interface */
removeEventListener(type: 'change', callback: EventListener): void;
/** Optimize condition with nested hierarchy */
optimize(): IMediaQueryCondition;
/** Returns serialized value of the condition (any IMediaQueryCondition instance should be able to be serializable) */
toString(): string;
}
/** A custom event dispatched by {@link ESLMediaQuery} instances */
export declare class ESLMediaChangeEvent extends Event {
static readonly TYPE = "change";
readonly type: typeof ESLMediaChangeEvent.TYPE;
/** `true` if the query is matched device conditions when event was dispatched */
readonly matches: boolean;
readonly target: IMediaQueryCondition;
constructor(matches: boolean);
/** Returns serialized value of the current {@link ESLMediaQuery} */
get media(): string;
}