本文整理匯總了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 ;
//.........這裏部分代碼省略.........