本文整理汇总了TypeScript中core/dom.children函数的典型用法代码示例。如果您正苦于以下问题:TypeScript children函数的具体用法?TypeScript children怎么用?TypeScript children使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了children函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _update_layout
_update_layout(): void {
const loc = this.model.tabs_location
this.header = new LayoutItem()
const size = Math.max(...children(this.header_el).map((el) => outer_size(el).height))
if (loc == "above" || loc == "below")
this.header.set_sizing({width_policy: "fit", height_policy: "fixed", height: size})
else
this.header.set_sizing({width_policy: "fixed", width: size, height_policy: "fit"})
let row = 1
let col = 1
switch (loc) {
case "above": row -= 1; break
case "below": row += 1; break
case "left": col -= 1; break
case "right": col += 1; break
}
const header = {layout: this.header, row, col}
const panels = this.child_views.map((child_view) => {
return {layout: child_view.layout, row: 1, col: 1}
})
this.layout = new Grid([header, ...panels])
this.layout.set_sizing(this.box_sizing())
}
示例2: return
return () => {
const ntabs = this.model.tabs.length
if (dir == "left")
scroll_index = Math.max(scroll_index - 1, 0)
else
scroll_index = Math.min(scroll_index + 1, ntabs - 1)
if (scroll_index == 0)
left_el.setAttribute("disabled", "")
else
left_el.removeAttribute("disabled")
if (scroll_index == ntabs - 1)
right_el.setAttribute("disabled", "")
else
right_el.removeAttribute("disabled")
const sizes = children(this.headers_el)
.slice(0, scroll_index)
.map((el) => el.getBoundingClientRect())
if (vertical) {
const left = -sum(sizes.map((size) => size.width))
this.headers_el.style.left = `${left}px`
} else {
const top = -sum(sizes.map((size) => size.height))
this.headers_el.style.top = `${top}px`
}
}
示例3: on_active_change
on_active_change(): void {
const i = this.model.active
const headers = children(this.header_el)
for (const el of headers)
el.classList.remove("bk-active")
headers[i].classList.add("bk-active")
const {child_views} = this
for (const child_view of child_views)
hide(child_view.el)
show(child_views[i].el)
}
示例4: _measure
protected _measure(viewport: Sizeable) {
const min_headers = 3
const scroll = size(scroll_el)
const headers = children(headers_el).slice(0, min_headers).map((el) => size(el))
const {width, height} = super._measure(viewport)
if (vertical) {
const min_width = scroll.width + sum(headers.map((size) => size.width))
return {width: viewport.width != Infinity ? viewport.width : min_width, height}
} else {
const min_height = scroll.height + sum(headers.map((size) => size.height))
return {width, height: viewport.height != Infinity ? viewport.height : min_height}
}
}