本文整理汇总了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})
}