push
travis-ci
66 of 66 new or added lines in 3 files covered. (100.0%)
397 of 593 relevant lines covered (66.95%)
5.38 hits per line
1 |
/**
|
|
2 |
* 获取 node 上的 align 对齐点 相对于页面的坐标 |
|
3 |
*/ |
1✔ |
4 |
|
|
5 |
function getAlignOffset(region, align) { |
|
6 |
const V = align.charAt(0);
|
|
7 |
const H = align.charAt(1);
|
|
8 |
const w = region.width; |
|
9 |
const h = region.height; |
|
10 |
let x; |
1✔ |
11 |
let y; |
8✔ |
12 |
|
8✔ |
13 |
x = region.left; |
8✔ |
14 |
y = region.top; |
8✔ |
15 |
|
8✔ |
16 |
if (V === 'c') { |
8✔ |
17 |
y += h / 2;
|
|
18 |
} else if (V === 'b') { |
8✔ |
19 |
y += h; |
8✔ |
20 |
} |
|
21 |
|
8✔ |
22 |
if (H === 'c') { |
× |
23 |
x += w / 2;
|
8✔ |
24 |
} else if (H === 'r') { |
× |
25 |
x += w; |
|
26 |
} |
|
27 |
|
8✔ |
28 |
return {
|
× |
29 |
left: x,
|
8✔ |
30 |
top: y,
|
× |
31 |
}; |
|
32 |
} |
|
33 |
|
8✔ |
34 |
export default getAlignOffset; |