Interface MediaQueryList
matches: boolean;
media: string;
onchange: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null;
addEventListener<K extends "change">(
type: K,
listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
addListener(
callback:
| ((this: MediaQueryList, ev: MediaQueryListEvent) => any)
| null,
): void;
dispatchEvent(event: Event): boolean;
removeEventListener<K extends "change">(
type: K,
listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
removeListener(
callback:
| ((this: MediaQueryList, ev: MediaQueryListEvent) => any)
| null,
): void;
}
Hierarchy
- EventTarget
- MediaQueryList
Index
Properties
Methods
Properties
Readonlymatches
The matches read-only property of the true if the document currently matches the media query list, or false if not.
Readonlymedia
The media read-only property of the serialized media query.
onchange
Methods
addEventListener
- addEventListener<K extends "change">(
type: K,
listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Type Parameters
- K extends "change"
Parameters
- type: K
- listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any
Optionaloptions: boolean | AddEventListenerOptions
Returns void
- addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | AddEventListenerOptions
Returns void
addListener
The deprecated
addListener()method of theMediaQueryListenerthat will run a custom callback function in response to the media query status changing.Parameters
- callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null
Returns void
dispatchEvent
The
dispatchEvent()method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.Parameters
- event: Event
Returns boolean
removeEventListener
- removeEventListener<K extends "change">(
type: K,
listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Type Parameters
- K extends "change"
Parameters
- type: K
- listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any
Optionaloptions: boolean | EventListenerOptions
Returns void
- removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | EventListenerOptions
Returns void
removeListener
The
removeListener()method of theMediaQueryListener.Parameters
- callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null
Returns void
A
MediaQueryListobject stores information on a media query applied to a document, with support for both immediate and event-driven matching against the state of the document.MDN Reference