UIElement

UIElement

new UIElement(data)

Source:
Parameters:
Name Type Description
data Object

预设元素数据

Members

attributes :Object

元素属性映射表

Source:
Type:

children :Array.<UIElement>

子元素列表

Source:
Type:

connected :boolean

元素是否已经连接

Source:
Type:
  • boolean

events :Object

元素事件映射表

Source:
Type:

height :number

元素高度(自动计算值)

Source:
Type:
  • number

matrix :Matrix

元素变换矩阵

Source:
Type:

name :string

元素名称

Source:
Type:
  • string

opacity :number

元素不透明度(自动计算值)

Source:
Type:
  • number

parent :UIElement|null

父级元素对象

Source:
Type:

pointerEvents :boolean

元素是否已激活指针事件

Source:
Type:
  • boolean

presetId :string

预设元素数据ID

Source:
Type:
  • string

script :Script

元素脚本管理器

Source:
Type:

transform :Object

元素变换数据

Source:
Type:

updaters :ModuleList

元素更新器模块列表

Source:
Type:

visible :boolean

元素可见性

Source:
Type:
  • boolean

width :number

元素宽度(自动计算值)

Source:
Type:
  • number

x :number

元素水平位置(自动计算值)

Source:
Type:
  • number

y :number

元素垂直位置(自动计算值)

Source:
Type:
  • number

Methods

appendChild(element)

添加子元素

Source:
Parameters:
Name Type Description
element UIElement

元素

appendChildren(elements)

添加多个子元素

Source:
Parameters:
Name Type Description
elements Array.<UIElement>

元素列表

calculatePosition()

使用变换参数来计算元素的实际位置

Source:

callEvent(type, bubbleopt) → {EventHandler|undefined}

调用元素事件

Source:
Parameters:
Name Type Attributes Default Description
type string

元素事件类型

bubble boolean <optional>
false

是否传递事件

Returns:
Type:
EventHandler | undefined

clear() → {UIElement}

清除所有子元素

Source:
Returns:
Type:
UIElement

connect()

连接元素

Source:

connectChildren()

连接所有子元素

Source:

contains(element) → {boolean}

判断是否包含指定元素

Source:
Parameters:
Name Type Description
element UIElement

目标元素

Returns:
Type:
boolean

destroy()

销毁元素

Source:

destroyChildren()

销毁所有子元素

Source:

disconnect()

断开元素

Source:

disconnectChildren()

断开所有子元素

Source:

drawChildren()

绘制所有子元素

Source:

emit(type, bubbleopt)

调用元素事件和脚本

Source:
Parameters:
Name Type Attributes Default Description
type string

元素事件类型

bubble boolean <optional>
false

是否传递事件

hide() → {UIElement}

隐藏元素

Source:
Returns:
Type:
UIElement

insertBefore(element, destination)

插入子元素到目标元素前面

Source:
Parameters:
Name Type Description
element UIElement

新插入的元素

destination UIElement

目标位置的元素

isPointIn(x, y) → {boolean}

判断屏幕坐标点是否在元素区域内

Source:
Parameters:
Name Type Description
x number

屏幕X

y number

屏幕Y

Returns:
Type:
boolean

isVisible() → {boolean}

判断是否可见

Source:
Returns:
Type:
boolean

move(transformProps, easingIdopt, durationopt)

移动元素

Source:
Parameters:
Name Type Attributes Description
transformProps Object

元素变换属性选项

easingId string <optional>

过渡曲线ID

duration number <optional>

持续时间(毫秒)

moveToIndex(pos)

将元素移动到父级列表中指定的索引位置

Source:
Parameters:
Name Type Description
pos number

目标索引位置

query(key, value) → {UIElement|undefined}

查询属性匹配的后代元素

Source:
Parameters:
Name Type Description
key string

属性键

value any

属性值

Returns:
Type:
UIElement | undefined

remove()

从父级元素中移除

Source:

resizeChildren()

调整所有子元素

Source:

set(transformProps)

设置元素位置

Source:
Parameters:
Name Type Description
transformProps Object

元素变换属性选项

show() → {UIElement}

显示元素

Source:
Returns:
Type:
UIElement