-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from /issues/74-typescript-def
Issues/74 typescript def
- Loading branch information
Showing
4 changed files
with
103 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
declare module 'opentok-layout-js' { | ||
type alignOptions = 'start' | 'center' | 'end'; | ||
|
||
export type Options = { | ||
alignItems: alignOptions; | ||
animate: boolean; | ||
bigAlignItems: alignOptions; | ||
bigClass: string; | ||
bigFirst: boolean; | ||
bigFixedRatio: false; | ||
bigMaxHeight: number; | ||
bigMaxRatio: number; | ||
bigMaxWidth: number; | ||
bigMinRatio: number; | ||
bigPercentage: number; | ||
fixedRatio: boolean; | ||
ignoreClass: string; | ||
maxHeight: number; | ||
maxRatio: number; | ||
maxWidth: number; | ||
minRatio: number; | ||
smallAlignItems: alignOptions; | ||
smallMaxHeight: number; | ||
smallMaxWidth: number; | ||
window: Window; | ||
}; | ||
|
||
type Element = { | ||
big: boolean; | ||
height: number; | ||
width: number; | ||
}; | ||
|
||
type Box = { | ||
height: number; | ||
left: number; | ||
top: number; | ||
width: number; | ||
}; | ||
|
||
type GetLayout = (elements: Array<Element>) => Array<Box>; | ||
|
||
export type LayoutContainer = { | ||
getLayout: GetLayout; | ||
layout: () => void; | ||
}; | ||
|
||
export default function initLayoutContainer( | ||
container: HTMLElement | string, | ||
opts: Options | ||
): LayoutContainer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/// <reference path="opentok-layout-js.d.ts" /> | ||
|
||
import initLayoutContainer, { Options } from "opentok-layout-js"; | ||
|
||
/* eslint-disable */ | ||
|
||
|
||
const options: Options = { | ||
maxRatio: 3/2, | ||
minRatio: 9/16, | ||
fixedRatio: false, | ||
alignItems: 'center', | ||
bigClass: "OT_big", | ||
bigPercentage: 0.8, | ||
bigFixedRatio: false, | ||
bigAlignItems: 'center', | ||
smallAlignItems: 'center', | ||
maxWidth: Infinity, | ||
maxHeight: Infinity, | ||
smallMaxWidth: Infinity, | ||
smallMaxHeight: Infinity, | ||
bigMaxWidth: Infinity, | ||
bigMaxHeight: Infinity, | ||
bigMaxRatio: 3/2, | ||
bigMinRatio: 9/16, | ||
bigFirst: true, | ||
animate: true, | ||
window: window, | ||
ignoreClass: 'OT_ignore', | ||
}; | ||
|
||
const target = document.createElement('div'); | ||
|
||
const layout = initLayoutContainer(target, options) | ||
|
||
layout.layout(); | ||
|
||
const boxes = layout.getLayout([ | ||
{ | ||
width: 640, // The native width of this element (eg. subscriber.videoWidth()) | ||
height: 480, // The native height of this element (eg. subscriber.videoHeight()) | ||
big: false // Whether to treat this element as a bigger element | ||
} | ||
]); |