Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#60099 fix(video.js): add `requestNamedAnim…
Browse files Browse the repository at this point in the history
  • Loading branch information
peterblazejewicz authored Apr 27, 2022
1 parent 8037183 commit 44fdc86
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
22 changes: 18 additions & 4 deletions types/video.js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ declare namespace videojs {
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/media.html#audiotracklist}
*/
interface AudioTrackList extends TrackList {
interface AudioTrackList extends TrackList {
[index: number]: VideojsAudioTrack;

/**
Expand Down Expand Up @@ -1608,7 +1608,7 @@ declare namespace videojs {
* @return The descendant `Component` following the given descendant
* `names` or undefined.
*/
getDescendant(...names: Array<(string|string[])>): Component|undefined;
getDescendant(...names: Array<string | string[]>): Component | undefined;

/**
* Returns the child `Component` with the given `id`.
Expand Down Expand Up @@ -1805,6 +1805,20 @@ declare namespace videojs {
*/
requestAnimationFrame(fn: Component.GenericCallback): number;

/**
* Request an animation frame, but only one named animation
* frame will be queued. Another will never be added until
* the previous one finishes.
*
* @param name
* The name to give this requestAnimationFrame
*
* @param fn
* A function that will be bound to this component and executed just
* before the browser's next repaint.
*/
requestNamedAnimationFrame(name: string, fn: Component.GenericCallback): string | undefined;

/**
* Set the value of an attribute on the `Component`'s element
*
Expand Down Expand Up @@ -3937,12 +3951,12 @@ declare namespace videojs {
/**
* Determines the height of the floating video window.
*/
height: number;
height: number;

/**
* Determines the width of the floating video window.
*/
width: number;
width: number;
}

type Player = VideoJsPlayer;
Expand Down
9 changes: 6 additions & 3 deletions types/video.js/video.js-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ videojs('example_video_1', playerOptions).ready(function playerReady() {
pipWindow;
});

// $ExpectType string | undefined
this.requestNamedAnimationFrame('animationFrameName', () => {});

// $ExpectType Promise<void>
this.exitPictureInPicture();

Expand Down Expand Up @@ -232,7 +235,7 @@ function testComponents(player: videojs.Player) {
myWindow.isDisposed(); // $ExpectType boolean
myWindow.dispose(); // $ExpectType void

const MyOtherWindow = videojs.extend(videojs.getComponent("ModalDialog"), {
const MyOtherWindow = videojs.extend(videojs.getComponent('ModalDialog'), {
myFunction() {
this.player().play();
},
Expand All @@ -243,11 +246,11 @@ function testComponents(player: videojs.Player) {
});

const myOtherWindow = new MyOtherWindow(player, {});
myOtherWindow.controlText("My text");
myOtherWindow.controlText('My text');
myOtherWindow.open();
myOtherWindow.close();
myOtherWindow.myFunction(); // $ExpectType void
myOtherWindow.myOtherFunction("test"); // $ExpectType string
myOtherWindow.myOtherFunction('test'); // $ExpectType string
}

function testPlugin(player: videojs.Player, options: {}) {
Expand Down

0 comments on commit 44fdc86

Please sign in to comment.