new require("zrender/Group")()
Group.js, line 34
Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上
Example
var Group = require('zrender/Group');
var Circle = require('zrender/shape/Circle');
var g = new Group();
g.position[0] = 100;
g.position[1] = 100;
g.addChild(new Circle({
style: {
x: 100,
y: 100,
r: 20,
brushType: 'fill'
}
}));
zr.addGroup(g);
Members
-
clipShapemodule:zrender/shape/Base
-
用于裁剪的图形(shape),所有 Group 内的图形在绘制时都会被这个图形裁剪 该图形会继承Group的变换
-
idstring
-
Group id
-
ignoreboolean
-
是否忽略该 Group 及其所有子节点
- Default Value:
- false
-
typestring
-
-
inherited positionArray.<number>
-
平移
- Default Value:
- [0, 0]
-
inherited rotationArray.<number>
-
旋转,可以通过数组二三项指定旋转的原点
- Default Value:
- [0, 0, 0]
-
inherited scaleArray.<number>
-
缩放,可以通过数组三四项指定缩放的原点
- Default Value:
- [1, 1, 0, 0]
Methods
-
addChild(child)
Group.js, line 101 -
添加子节点,可以是Shape或者Group
Name Type Description child
module:zrender/Group | module:zrender/shape/Base -
childAt(idx){module:zrender/Group|module:zrender/shape/Base}
Group.js, line 92 -
获取指定 index 的儿子节点
Name Type Description idx
number -
children(){Array.<(module:zrender/Group|module:zrender/shape/Base)>}
Group.js, line 83 -
复制并返回一份新的包含所有儿子节点的数组
-
clearChildren()
Group.js, line 150 -
移除所有子节点
-
eachChild(cb, context)
Group.js, line 168 -
遍历所有子节点
Name Type Description cb
function context
-
removeChild(child)
Group.js, line 131 -
移除子节点
Name Type Description child
module:zrender/Group | module:zrender/shape/Base -
traverse(cb, context)
Group.js, line 185 -
深度优先遍历所有子孙节点
Name Type Description cb
function context
-
inherited bind(event, handler, context)
mixin/Eventful.js, line 50 -
绑定事件
Name Type Description event
string 事件名
handler
function 事件处理函数
context
Object optional -
inherited decomposeTransform()
mixin/Transformable.js, line 217 -
分解
transform
矩阵到position
,rotation
,scale
-
inherited dispatch(type)
mixin/Eventful.js, line 110 -
事件分发
Name Type Description type
string 事件类型
-
inherited dispatchWithContext(type)
mixin/Eventful.js, line 156 -
带有context的事件分发, 最后一个参数是事件回调的context
Name Type Description type
string 事件类型
-
inherited lookAt(target)
mixin/Transformable.js, line 188 -
设置图形的朝向
Name Type Description target
Array.<number> | Float32Array -
inherited one(event, handler, context)
mixin/Eventful.js, line 24 -
单次触发绑定,dispatch后销毁
Name Type Description event
string 事件名
handler
function 响应函数
context
Object -
inherited setTransform(ctx)
mixin/Transformable.js, line 173 -
将自己的transform应用到context上
Name Type Description ctx
Context2D -
inherited unbind(event, handler)
mixin/Eventful.js, line 75 -
解绑事件
Name Type Description event
string 事件名
handler
function optional 事件处理函数
-
inherited updateTransform()
mixin/Transformable.js, line 80 -
判断是否需要有坐标变换,更新needTransform属性。 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵
Events
-
inherited onclick
mixin/Eventful.js, line 200 -
Type:
- function
- Default Value:
- null
-
inherited ondragend
mixin/Eventful.js, line 240 -
Type:
- function
- Default Value:
- null
-
inherited ondragenter
mixin/Eventful.js, line 245 -
Type:
- function
- Default Value:
- null
-
inherited ondragleave
mixin/Eventful.js, line 250 -
Type:
- function
- Default Value:
- null
-
inherited ondragover
mixin/Eventful.js, line 255 -
Type:
- function
- Default Value:
- null
-
inherited ondragstart
mixin/Eventful.js, line 235 -
Type:
- function
- Default Value:
- null
-
inherited ondrop
mixin/Eventful.js, line 260 -
Type:
- function
- Default Value:
- null
-
inherited onmousedown
mixin/Eventful.js, line 225 -
Type:
- function
- Default Value:
- null
-
inherited onmousemove
mixin/Eventful.js, line 215 -
Type:
- function
- Default Value:
- null
-
inherited onmouseout
mixin/Eventful.js, line 210 -
Type:
- function
- Default Value:
- null
-
inherited onmouseover
mixin/Eventful.js, line 205 -
Type:
- function
- Default Value:
- null
-
inherited onmouseup
mixin/Eventful.js, line 230 -
Type:
- function
- Default Value:
- null
-
inherited onmousewheel
mixin/Eventful.js, line 220 -
Type:
- function
- Default Value:
- null