Repository navigation
Expand file tree
/
Copy pathindex.d.ts
More file actions
90 lines (76 loc) · 3.08 KB
/
Copy pathindex.d.ts
File metadata and controls
90 lines (76 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { AbortSignal } from 'bare-abort-controller'
interface AnimationFrameOptions {
/**
* Take back the request once `signal` is aborted. A promise is then rejected with the reason that
* `signal` was aborted with.
*/
signal?: AbortSignal
}
/** A requested frame, whose callback has yet to be called. */
interface AnimationFrameRequest {
/** Take back the request, unless its callback has already been called. */
cancel(): void
/** Cancel the request, so that `using` takes it back at the end of its scope. */
[Symbol.dispose](): void
}
/**
* The animation frame callbacks of a single target, as the `AnimationFrameProvider` of the HTML
* specification. On Apple, frames follow `target` if given, which is a view, window or screen. On
* linux, they follow `target` if given, which is a realized widget. Elsewhere, `target` is ignored.
*/
interface AnimationFrameProvider {
/**
* Call `callback` once, before the next frame is laid out and drawn, with the time the frame
* started in milliseconds, as read from `bare-hrtime`.
*/
requestAnimationFrame(
callback: (time: number) => void,
opts?: AnimationFrameOptions
): AnimationFrameRequest
/**
* Resolve before the next frame is laid out and drawn, with the time the frame started, so changes
* made then are part of the frame.
*/
requestAnimationFrame(opts?: AnimationFrameOptions): Promise<number>
/** Take back a request whose callback has not been called yet, as `request.cancel()` does. */
cancelAnimationFrame(request: AnimationFrameRequest): void
/**
* Call `callback` once every change made before the call has been laid out and drawn, by
* requesting a frame from within a frame. It is called with the time that the frame after
* started.
*/
afterAnimationFrame(
callback: (time: number) => void,
opts?: AnimationFrameOptions
): AnimationFrameRequest
/**
* Resolve once every change made before the call has been laid out and drawn, with the time that
* the frame after started.
*/
afterAnimationFrame(opts?: AnimationFrameOptions): Promise<number>
}
declare class AnimationFrameProvider {
/**
* Without `target`, frames follow the main screen on Apple and the active window of the
* application on Linux.
*/
constructor(target?: unknown)
/** `requestAnimationFrame()` of the default provider, which has no target. */
static requestAnimationFrame(
callback: (time: number) => void,
opts?: AnimationFrameOptions
): AnimationFrameRequest
static requestAnimationFrame(opts?: AnimationFrameOptions): Promise<number>
/** `cancelAnimationFrame()` of the default provider. */
static cancelAnimationFrame(request: AnimationFrameRequest): void
/** `afterAnimationFrame()` of the default provider. */
static afterAnimationFrame(
callback: (time: number) => void,
opts?: AnimationFrameOptions
): AnimationFrameRequest
static afterAnimationFrame(opts?: AnimationFrameOptions): Promise<number>
}
declare namespace AnimationFrameProvider {
export { type AnimationFrameOptions, type AnimationFrameRequest }
}
export = AnimationFrameProvider