4 Star 5 Fork 2

Gitee 极速下载/zdog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/metafizzy/zdog
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
group.js 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
/**
* Group
*/
( function( root, factory ) {
// module definition
if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory( require('./anchor') );
} else {
// browser global
var Zdog = root.Zdog;
Zdog.Group = factory( Zdog.Anchor );
}
}( this, function factory( Anchor ) {
var Group = Anchor.subclass({
updateSort: false,
visible: true,
});
// ----- update ----- //
Group.prototype.updateSortValue = function() {
var sortValueTotal = 0;
this.flatGraph.forEach( function( item ) {
item.updateSortValue();
sortValueTotal += item.sortValue;
} );
// average sort value of all points
// def not geometrically correct, but works for me
this.sortValue = sortValueTotal / this.flatGraph.length;
if ( this.updateSort ) {
this.flatGraph.sort( Anchor.shapeSorter );
}
};
// ----- render ----- //
Group.prototype.render = function( ctx, renderer ) {
if ( !this.visible ) {
return;
}
this.flatGraph.forEach( function( item ) {
item.render( ctx, renderer );
} );
};
// actual group flatGraph only used inside group
Group.prototype.updateFlatGraph = function() {
// do not include self
var flatGraph = [];
this.flatGraph = this.addChildFlatGraph( flatGraph );
};
// do not include children, group handles rendering & sorting internally
Group.prototype.getFlatGraph = function() {
return [ this ];
};
return Group;
} ) );
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/zdog.git
git@gitee.com:mirrors/zdog.git
mirrors
zdog
zdog
master

搜索帮助

371d5123 14472233 46e8bd33 14472233