本文整理汇总了TypeScript中@angular/core.ElementRef.getClientRects方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ElementRef.getClientRects方法的具体用法?TypeScript ElementRef.getClientRects怎么用?TypeScript ElementRef.getClientRects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/core.ElementRef
的用法示例。
在下文中一共展示了ElementRef.getClientRects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: myLayout
myLayout(el:ElementRef) {
let container = el.getClientRects()[0];
let c_width = container.width, //container-height
c_height = container.height,
h_width = 150, //hex size
h_height = 86,
w_dist = 6,
h_dist = 46;
}
示例2: myLayout
myLayout(el:ElementRef) {
let container = el.getClientRects()[0];
let c_width = container.width, //container-height
c_height = container.height,
h_width = 150, //hex size
h_height = 86,
w_dist = 6,
h_dist = 46;
if (c_width>639) {
let pad_left = c_width/2 - (h_width + w_dist) * 4/2,
level_top1 = 55,
level_height = h_height + h_dist + w_dist/2,
row_width = h_width + w_dist;
//layer 1
el.children[0].style.left = pad_left + 1.5*row_width;
el.children[0].style.top = level_top1;
//layer 2
el.children[1].style.left = pad_left + row_width;
el.children[1].style.top = level_top1 + level_height;
el.children[2].style.left = pad_left + 2*row_width;
el.children[2].style.top = level_top1 + level_height;
//layer 3
el.children[3].style.left = pad_left + 0.5*row_width;
el.children[3].style.top = level_top1 + 2*level_height;
el.children[9].style.left = pad_left + 1.5*row_width;
el.children[9].style.top = level_top1 + 2*level_height + 13 ;
el.children[4].style.left = pad_left + 2.5*row_width ;
el.children[4].style.top = level_top1 + 2*level_height ;
//layer 4
el.children[6].style.left = pad_left + 0*row_width;
el.children[6].style.top = level_top1 + 3*level_height ;
el.children[7].style.left = pad_left + 1*row_width ;
el.children[7].style.top = level_top1 + 3 * level_height;
el.children[8].style.left = pad_left + 2 * row_width ;
el.children[8].style.top = level_top1 + 3 * level_height ;
el.children[5].style.left = pad_left + 3*row_width;
el.children[5].style.top = level_top1 + 3 * level_height ;
} else if (c_width > 480 ) {
let pad_left = c_width/2 - (h_width + w_dist) * 3/2,
level_top1 = 55,
level_height = h_height + h_dist + w_dist/2,
row_width = h_width + w_dist;
//layer 1
el.children[0].style.left = pad_left ;
el.children[0].style.top = level_top1;
el.children[1].style.left = pad_left + row_width;
el.children[1].style.top = level_top1;
el.children[2].style.left = pad_left + 2*row_width;
el.children[2].style.top = level_top1;
//layer 2
el.children[3].style.left = pad_left + 0.5*row_width;
el.children[3].style.top = level_top1 + level_height ;
el.children[4].style.left = pad_left + 1.5*row_width ;
el.children[4].style.top = level_top1 + level_height ;
//lay-3
el.children[9].style.left = pad_left + 1*row_width;
el.children[9].style.top = level_top1 + 2 * level_height + 13;
//lay-4
el.children[5].style.left = pad_left + 0.5*row_width;
el.children[5].style.top = level_top1 + 3*level_height ;
el.children[6].style.left = pad_left + 1.5*row_width;
el.children[6].style.top = level_top1 + 3*level_height ;
//layer 5
el.children[7].style.left = pad_left ;
el.children[7].style.top = level_top1 + 4 * level_height;
el.children[8].style.left = pad_left + 1 * row_width ;
el.children[8].style.top = level_top1 + 4 * level_height ;
//.........这里部分代码省略.........