Skip to content

Commit 2b23429

Browse files
committed
add Screen Orientation types
1 parent 53f57f7 commit 2b23429

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

baselines/dom.generated.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13760,6 +13760,7 @@ interface Screen extends EventTarget {
1376013760
readonly logicalYDPI: number;
1376113761
readonly msOrientation: string;
1376213762
onmsorientationchange: ((this: Screen, ev: Event) => any) | null;
13763+
readonly orientation: ScreenOrientation;
1376313764
readonly pixelDepth: number;
1376413765
readonly systemXDPI: number;
1376513766
readonly systemYDPI: number;
@@ -13779,6 +13780,27 @@ declare var Screen: {
1377913780
new(): Screen;
1378013781
};
1378113782

13783+
interface ScreenOrientationEventMap {
13784+
"change": Event;
13785+
}
13786+
13787+
interface ScreenOrientation extends EventTarget {
13788+
readonly angle: number;
13789+
onchange: ((this: ScreenOrientation, ev: Event) => any) | null;
13790+
readonly type: OrientationType;
13791+
lock(orientation: OrientationLockType): Promise<void>;
13792+
unlock(): void;
13793+
addEventListener<K extends keyof ScreenOrientationEventMap>(type: K, listener: (this: ScreenOrientation, ev: ScreenOrientationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
13794+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
13795+
removeEventListener<K extends keyof ScreenOrientationEventMap>(type: K, listener: (this: ScreenOrientation, ev: ScreenOrientationEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
13796+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
13797+
}
13798+
13799+
declare var ScreenOrientation: {
13800+
prototype: ScreenOrientation;
13801+
new(): ScreenOrientation;
13802+
};
13803+
1378213804
interface ScriptProcessorNodeEventMap {
1378313805
"audioprocess": AudioProcessingEvent;
1378413806
}
@@ -17225,6 +17247,8 @@ type NavigationReason = "up" | "down" | "left" | "right";
1722517247
type NavigationType = "navigate" | "reload" | "back_forward" | "prerender";
1722617248
type NotificationDirection = "auto" | "ltr" | "rtl";
1722717249
type NotificationPermission = "default" | "denied" | "granted";
17250+
type OrientationLockType = "any" | "natural" | "landscape" | "portrait" | "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
17251+
type OrientationType = "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
1722817252
type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom";
1722917253
type OverSampleType = "none" | "2x" | "4x";
1723017254
type PanningModelType = "equalpower" | "HRTF";
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
partial interface Screen {
2+
[SameObject]
3+
readonly attribute ScreenOrientation orientation;
4+
};
5+
6+
[Exposed=Window]
7+
interface ScreenOrientation : EventTarget {
8+
Promise<void> lock(OrientationLockType orientation);
9+
void unlock();
10+
readonly attribute OrientationType type;
11+
readonly attribute unsigned short angle;
12+
attribute EventHandler onchange;
13+
};
14+
15+
enum OrientationType {
16+
"portrait-primary",
17+
"portrait-secondary",
18+
"landscape-primary",
19+
"landscape-secondary"
20+
};
21+
22+
enum OrientationLockType {
23+
"any",
24+
"natural",
25+
"landscape",
26+
"portrait",
27+
"portrait-primary",
28+
"portrait-secondary",
29+
"landscape-primary",
30+
"landscape-secondary"
31+
};

inputfiles/idlSources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
"url": "https://w3c.github.io/resource-timing/",
8181
"title": "Resource Timing"
8282
},
83+
{
84+
"url": "https://www.w3.org/TR/screen-orientation/",
85+
"title": "Screen Orientation"
86+
},
8387
{
8488
"url": "https://w3c.github.io/ServiceWorker/",
8589
"title": "Service Workers"

0 commit comments

Comments
 (0)