Skip to content

Commit c3abecf

Browse files
authored
Merge pull request #128 from SaschaNaz/scrollExtension
Add scroll extension
2 parents d9e593c + 9a153e5 commit c3abecf

File tree

3 files changed

+134
-2
lines changed

3 files changed

+134
-2
lines changed

baselines/dom.generated.d.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3675,6 +3675,13 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
36753675
getElementsByClassName(classNames: string): NodeListOf<Element>;
36763676
matches(selector: string): boolean;
36773677
closest(selector: string): Element | null;
3678+
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
3679+
scroll(options?: ScrollToOptions): void;
3680+
scroll(x: number, y: number): void;
3681+
scrollTo(options?: ScrollToOptions): void;
3682+
scrollTo(x: number, y: number): void;
3683+
scrollBy(options?: ScrollToOptions): void;
3684+
scrollBy(x: number, y: number): void;
36783685
insertAdjacentElement(position: string, insertedElement: Element): Element | null;
36793686
insertAdjacentHTML(where: string, html: string): void;
36803687
insertAdjacentText(where: string, text: string): void;
@@ -4625,7 +4632,6 @@ interface HTMLElement extends Element {
46254632
dragDrop(): boolean;
46264633
focus(): void;
46274634
msGetInputContext(): MSInputMethodContext;
4628-
scrollIntoView(top?: boolean): void;
46294635
setActive(): void;
46304636
addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void;
46314637
addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -13002,6 +13008,9 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
1300213008
webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint;
1300313009
webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint;
1300413010
webkitRequestAnimationFrame(callback: FrameRequestCallback): number;
13011+
scroll(options?: ScrollToOptions): void;
13012+
scrollTo(options?: ScrollToOptions): void;
13013+
scrollBy(options?: ScrollToOptions): void;
1300513014
addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void;
1300613015
addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void;
1300713016
addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -14029,6 +14038,20 @@ interface ProgressEventInit extends EventInit {
1402914038
total?: number;
1403014039
}
1403114040

14041+
interface ScrollOptions {
14042+
behavior?: ScrollBehavior;
14043+
}
14044+
14045+
interface ScrollToOptions extends ScrollOptions {
14046+
left?: number;
14047+
top?: number;
14048+
}
14049+
14050+
interface ScrollIntoViewOptions extends ScrollOptions {
14051+
block?: ScrollLogicalPosition;
14052+
inline?: ScrollLogicalPosition;
14053+
}
14054+
1403214055
interface ClipboardEventInit extends EventInit {
1403314056
data?: string;
1403414057
dataType?: string;
@@ -14425,6 +14448,9 @@ declare function webkitCancelAnimationFrame(handle: number): void;
1442514448
declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint;
1442614449
declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint;
1442714450
declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number;
14451+
declare function scroll(options?: ScrollToOptions): void;
14452+
declare function scrollTo(options?: ScrollToOptions): void;
14453+
declare function scrollBy(options?: ScrollToOptions): void;
1442814454
declare function toString(): string;
1442914455
declare function addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
1443014456
declare function dispatchEvent(evt: Event): boolean;
@@ -14580,6 +14606,8 @@ type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload;
1458014606
type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete;
1458114607
type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport;
1458214608
type payloadtype = number;
14609+
type ScrollBehavior = "auto" | "instant" | "smooth";
14610+
type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
1458314611
type IDBValidKey = number | string | Date | IDBArrayKey;
1458414612
type BufferSource = ArrayBuffer | ArrayBufferView;
1458514613
type MouseWheelEvent = WheelEvent;

inputfiles/addedTypes.json

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,106 @@
241241
{
242242
"kind": "method",
243243
"interface": "Element",
244-
"signatures": ["closest(selector: string): Element | null"]
244+
"signatures": [ "closest(selector: string): Element | null" ]
245+
},
246+
{
247+
"kind": "typedef",
248+
"flavor": "Web",
249+
"name": "ScrollBehavior",
250+
"type": "\"auto\" | \"instant\" | \"smooth\""
251+
},
252+
{
253+
"kind": "interface",
254+
"flavor": "Web",
255+
"name": "ScrollOptions",
256+
"properties": [
257+
{
258+
"name": "behavior?",
259+
"type": "ScrollBehavior"
260+
}
261+
]
262+
},
263+
{
264+
"kind": "interface",
265+
"flavor": "Web",
266+
"name": "ScrollToOptions",
267+
"extends": "ScrollOptions",
268+
"properties": [
269+
{
270+
"name": "left?",
271+
"type": "number"
272+
},
273+
{
274+
"name": "top?",
275+
"type": "number"
276+
}
277+
]
278+
},
279+
{
280+
"kind": "method",
281+
"interface": "Window",
282+
"signatures": [ "scroll(options?: ScrollToOptions): void" ]
283+
},
284+
{
285+
"kind": "method",
286+
"interface": "Window",
287+
"signatures": [ "scrollTo(options?: ScrollToOptions): void" ]
288+
},
289+
{
290+
"kind": "method",
291+
"interface": "Window",
292+
"signatures": [ "scrollBy(options?: ScrollToOptions): void" ]
293+
},
294+
{
295+
"kind": "typedef",
296+
"flavor": "Web",
297+
"name": "ScrollLogicalPosition",
298+
"type": "\"start\" | \"center\" | \"end\" | \"nearest\""
299+
},
300+
{
301+
"kind": "interface",
302+
"flavor": "Web",
303+
"name": "ScrollIntoViewOptions",
304+
"extends": "ScrollOptions",
305+
"properties": [
306+
{
307+
"name": "block?",
308+
"type": "ScrollLogicalPosition"
309+
},
310+
{
311+
"name": "inline?",
312+
"type": "ScrollLogicalPosition"
313+
}
314+
]
315+
},
316+
{
317+
"kind": "method",
318+
"interface": "Element",
319+
"signatures": [ "scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void" ]
320+
},
321+
{
322+
"kind": "method",
323+
"interface": "Element",
324+
"signatures": [
325+
"scroll(options?: ScrollToOptions): void",
326+
"scroll(x: number, y: number): void"
327+
]
328+
},
329+
{
330+
"kind": "method",
331+
"interface": "Element",
332+
"signatures": [
333+
"scrollTo(options?: ScrollToOptions): void",
334+
"scrollTo(x: number, y: number): void"
335+
]
336+
},
337+
{
338+
"kind": "method",
339+
"interface": "Element",
340+
"signatures": [
341+
"scrollBy(options?: ScrollToOptions): void",
342+
"scrollBy(x: number, y: number): void"
343+
]
245344
},
246345
{
247346
"kind": "indexer",

inputfiles/removedTypes.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"interface": "HTMLElement",
2020
"name": "contains"
2121
},
22+
{
23+
"kind": "method",
24+
"interface": "HTMLElement",
25+
"name": "scrollIntoView"
26+
},
2227
{
2328
"kind": "method",
2429
"interface": "StorageEvent",

0 commit comments

Comments
 (0)