本文整理匯總了TypeScript中core/util/data_structures.Matrix類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Matrix類的具體用法?TypeScript Matrix怎麽用?TypeScript Matrix使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Matrix類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe("3x3 GridBox", () => {
const colors = Matrix.from([
["red", "green", "blue" ],
["gray", "orange", "fuchsia"],
["aqua", "maroon", "yellow" ],
])
it("fixed spacers 50px x 50px", async () => {
const s0 = spacer("fixed", "fixed", 50, 50)
const items = colors.apply([
[s0, s0, s0],
[s0, s0, s0],
[s0, s0, s0],
])
const l = grid(items)
await display(l, [300, 300])
})
it("fixed spacers 50px x 50px, spacing 5px", async () => {
const s0 = spacer("fixed", "fixed", 50, 50)
const items = colors.apply([
[s0, s0, s0],
[s0, s0, s0],
[s0, s0, s0],
])
const l = grid(items, {spacing: 5})
await display(l, [300, 300])
})
it("fixed spacers 50px x 50px, hspacing 5px, vspacing 10px", async () => {
const s0 = spacer("fixed", "fixed", 50, 50)
const items = colors.apply([
[s0, s0, s0],
[s0, s0, s0],
[s0, s0, s0],
])
const l = grid(items, {spacing: [5, 10]})
await display(l, [300, 300])
})
it("fixed and 1 x-max spacers, c2 auto", async () => {
const s0 = spacer("fixed", "fixed", 50, 50)
const s1 = spacer("max", "fixed", 50, 50)
const items = colors.apply([
[s0, s0, s1],
[s0, s0, s0],
[s0, s0, s0],
])
const l = grid(items, {cols: {2: {policy: "auto"}}})
await display(l, [300, 300])
})
it("fixed and 2 x-max spacers, c2 auto", async () => {
const s0 = spacer("fixed", "fixed", 50, 50)
const s1 = spacer("max", "fixed", 50, 50)
const items = colors.apply([
[s0, s1, s1],
[s0, s0, s0],
[s0, s0, s0],
])
const l = grid(items, {cols: {2: {policy: "auto"}}})
await display(l, [300, 300])
})
it("fixed and 2 x-max spacers, c2 flex=2", async () => {
const s0 = spacer("fixed", "fixed", 50, 50)
const s1 = spacer("max", "fixed", 50, 50)
const items = colors.apply([
[s0, s1, s1],
[s0, s0, s0],
[s0, s0, s0],
])
const l = grid(items, {cols: {2: {policy: "flex", factor: 2}}})
await display(l, [300, 300])
})
it("fixed and 3 x-max spacers, c2 flex=2", async () => {
const s0 = spacer("fixed", "fixed", 50, 50)
const s1 = spacer("max", "fixed", 50, 50)
const items = colors.apply([
[s1, s1, s1],
[s0, s0, s0],
[s0, s0, s0],
])
const l = grid(items, {cols: {2: {policy: "flex", factor: 2}}})
await display(l, [300, 300])
//.........這裏部分代碼省略.........
示例2: grid
function grid(items: Matrix<LayoutDOM> | LayoutDOM[][], opts?: Partial<GridBox.Attrs>): GridBox {
const children = Matrix.from(items).to_sparse()
return new GridBox({...opts, children})
}