@phun-ky/speccer 5.0.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +16 -3
- package/speccer.css +11 -19
- package/speccer.js +2 -1
- package/speccer.js.map +1 -0
- package/speccer.min.css +1 -1
- package/CHANGELOG.md +0 -59
- package/src/browser.js +0 -93
- package/src/dissect.js +0 -211
- package/src/index.js +0 -36
- package/src/lib/attributes.js +0 -13
- package/src/lib/classnames.js +0 -37
- package/src/lib/constants.js +0 -5
- package/src/lib/css.js +0 -37
- package/src/lib/debounce.js +0 -22
- package/src/lib/node.js +0 -7
- package/src/lib/number.js +0 -4
- package/src/lib/resize.js +0 -13
- package/src/lib/styles.js +0 -27
- package/src/measure.js +0 -99
- package/src/spec.js +0 -214
- package/src/styles/anatomy.styl +0 -274
- package/src/styles/index.styl +0 -68
- package/src/styles/measure.styl +0 -88
- package/src/styles/spacing.styl +0 -152
- package/src/styles/typography.styl +0 -86
- package/src/typography.js +0 -141
package/src/dissect.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
import * as styles from './lib/styles';
|
|
4
|
-
import * as node from './lib/node';
|
|
5
|
-
import * as classnames from './lib/classnames';
|
|
6
|
-
import { SPECCER_LITERALS, SPECCER_TAGS_TO_AVOID } from './lib/constants';
|
|
7
|
-
|
|
8
|
-
export const create = (e = '', t, n = 'span') => {
|
|
9
|
-
const _el = document.createElement(n);
|
|
10
|
-
const o = document.createTextNode(e);
|
|
11
|
-
|
|
12
|
-
if (t.indexOf('full') === -1 && t.indexOf('enclose') === -1) {
|
|
13
|
-
_el.appendChild(o);
|
|
14
|
-
} else if (t.indexOf('full') !== -1 || t.indexOf('enclose') !== -1) {
|
|
15
|
-
_el.setAttribute('data-dissection-counter', e);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
classnames.set(_el, `ph speccer dissection ${t}`);
|
|
19
|
-
|
|
20
|
-
return _el;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const element = (el, dissectIndex) => {
|
|
24
|
-
const _el_rect = el.getBoundingClientRect();
|
|
25
|
-
const _area = el.getAttribute('data-anatomy');
|
|
26
|
-
const _dissection_node = create(SPECCER_LITERALS[dissectIndex], _area);
|
|
27
|
-
const _is_table_correction_needed = SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0;
|
|
28
|
-
|
|
29
|
-
let _table_top = 0;
|
|
30
|
-
let _table_left = 0;
|
|
31
|
-
|
|
32
|
-
if (_is_table_correction_needed) {
|
|
33
|
-
const table = el.closest('table');
|
|
34
|
-
const tableStyle = styles.get(table.parentElement);
|
|
35
|
-
|
|
36
|
-
node.after(table, _dissection_node);
|
|
37
|
-
|
|
38
|
-
const _table_rect = table.getBoundingClientRect();
|
|
39
|
-
|
|
40
|
-
_table_top = _table_rect.top - parseInt(tableStyle.getPropertyValue('padding-top'), 10);
|
|
41
|
-
_table_left = _table_rect.left - parseInt(tableStyle.getPropertyValue('padding-left'), 10);
|
|
42
|
-
} else {
|
|
43
|
-
node.after(el, _dissection_node);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const _el_offset_left = el.offsetLeft;
|
|
47
|
-
const _el_offset_top = el.offsetTop;
|
|
48
|
-
const _dissection_node_rect = _dissection_node.getBoundingClientRect();
|
|
49
|
-
const _outline_left_position_left =
|
|
50
|
-
(_is_table_correction_needed ? _el_rect.left - _table_left : _el_offset_left) -
|
|
51
|
-
_dissection_node_rect.width -
|
|
52
|
-
48 +
|
|
53
|
-
'px';
|
|
54
|
-
const _outline_left_position_top =
|
|
55
|
-
(_is_table_correction_needed ? _el_rect.top - _table_top : _el_offset_top) +
|
|
56
|
-
_el_rect.height / 2 -
|
|
57
|
-
_dissection_node_rect.height / 2 +
|
|
58
|
-
'px';
|
|
59
|
-
const _outline_right_position_left =
|
|
60
|
-
(_is_table_correction_needed ? _el_rect.left - _table_left : _el_offset_left) + _el_rect.width + 48 + 'px';
|
|
61
|
-
const _outline_right_position_top =
|
|
62
|
-
(_is_table_correction_needed ? _el_rect.top - _table_top : _el_offset_top) +
|
|
63
|
-
_el_rect.height / 2 -
|
|
64
|
-
_dissection_node_rect.height / 2 +
|
|
65
|
-
'px';
|
|
66
|
-
const _outline_top_position_left =
|
|
67
|
-
(_is_table_correction_needed ? _el_rect.left - _table_left : _el_offset_left) +
|
|
68
|
-
_el_rect.width / 2 -
|
|
69
|
-
_dissection_node_rect.width / 2 +
|
|
70
|
-
'px';
|
|
71
|
-
const _outline_top_position_top =
|
|
72
|
-
(_is_table_correction_needed ? _el_rect.top - _table_top : _el_offset_top) -
|
|
73
|
-
_dissection_node_rect.height -
|
|
74
|
-
48 +
|
|
75
|
-
'px';
|
|
76
|
-
const _outline_bottom_position_left =
|
|
77
|
-
(_is_table_correction_needed ? _el_rect.left - _table_left : _el_offset_left) +
|
|
78
|
-
_el_rect.width / 2 -
|
|
79
|
-
_dissection_node_rect.width / 2 +
|
|
80
|
-
'px';
|
|
81
|
-
const _outline_bottom_position_top =
|
|
82
|
-
(_is_table_correction_needed ? _el_rect.top - _table_top : _el_offset_top) + _el_rect.height + 48 + 'px';
|
|
83
|
-
|
|
84
|
-
let _dissection_node_styles = {};
|
|
85
|
-
|
|
86
|
-
if (_area.indexOf('outline') !== -1) {
|
|
87
|
-
if (_area.indexOf('left') !== -1) {
|
|
88
|
-
if (_area.indexOf('full') !== -1) {
|
|
89
|
-
_dissection_node_styles = {
|
|
90
|
-
left: _el_offset_left - 8 + 'px',
|
|
91
|
-
top: _el_offset_top + -1 + 'px',
|
|
92
|
-
height: _el_rect.height + 'px'
|
|
93
|
-
};
|
|
94
|
-
} else if (_area.indexOf('enclose') !== -1) {
|
|
95
|
-
_dissection_node_styles = {
|
|
96
|
-
left: _el_offset_left - 1 + 'px',
|
|
97
|
-
top: _el_offset_top + -1 + 'px',
|
|
98
|
-
height: _el_rect.height + 'px',
|
|
99
|
-
width: _el_rect.width + 'px'
|
|
100
|
-
};
|
|
101
|
-
} else {
|
|
102
|
-
_dissection_node_styles = {
|
|
103
|
-
left: _outline_left_position_left,
|
|
104
|
-
top: _outline_left_position_top
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
} else if (_area.indexOf('right') !== -1) {
|
|
108
|
-
if (_area.indexOf('full') !== -1) {
|
|
109
|
-
_dissection_node_styles = {
|
|
110
|
-
left: _el_offset_left + _el_rect.width + 'px',
|
|
111
|
-
top: _el_offset_top + -1 + 'px',
|
|
112
|
-
height: _el_rect.height + 'px'
|
|
113
|
-
};
|
|
114
|
-
} else if (_area.indexOf('enclose') !== -1) {
|
|
115
|
-
_dissection_node_styles = {
|
|
116
|
-
left: _el_offset_left + -1 + 'px',
|
|
117
|
-
top: _el_offset_top + -1 + 'px',
|
|
118
|
-
height: _el_rect.height + 'px',
|
|
119
|
-
width: _el_rect.width + 'px'
|
|
120
|
-
};
|
|
121
|
-
} else {
|
|
122
|
-
_dissection_node_styles = {
|
|
123
|
-
left: _outline_right_position_left,
|
|
124
|
-
top: _outline_right_position_top
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
} else if (_area.indexOf('top') !== -1) {
|
|
128
|
-
if (_area.indexOf('full') !== -1) {
|
|
129
|
-
_dissection_node_styles = {
|
|
130
|
-
top: _el_offset_top + -8 + 'px',
|
|
131
|
-
left: _el_offset_left + -1 + 'px',
|
|
132
|
-
width: _el_rect.width + 'px'
|
|
133
|
-
};
|
|
134
|
-
} else if (_area.indexOf('enclose') !== -1) {
|
|
135
|
-
_dissection_node_styles = {
|
|
136
|
-
top: _el_offset_top + -1 + 'px',
|
|
137
|
-
left: _el_offset_left + -1 + 'px',
|
|
138
|
-
height: _el_rect.height + 'px',
|
|
139
|
-
width: _el_rect.width + 'px'
|
|
140
|
-
};
|
|
141
|
-
} else {
|
|
142
|
-
_dissection_node_styles = {
|
|
143
|
-
left: _outline_top_position_left,
|
|
144
|
-
top: _outline_top_position_top
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
} else if (_area.indexOf('bottom') !== -1) {
|
|
148
|
-
if (_area.indexOf('full') !== -1) {
|
|
149
|
-
_dissection_node_styles = {
|
|
150
|
-
top: _el_offset_top + _el_rect.height + 'px',
|
|
151
|
-
left: _el_offset_left + -1 + 'px',
|
|
152
|
-
width: _el_rect.width + 'px'
|
|
153
|
-
};
|
|
154
|
-
} else if (_area.indexOf('enclose') !== -1) {
|
|
155
|
-
_dissection_node_styles = {
|
|
156
|
-
top: _el_offset_top + -1 + 'px',
|
|
157
|
-
left: _el_offset_left + -1 + 'px',
|
|
158
|
-
height: _el_rect.height + 'px',
|
|
159
|
-
width: _el_rect.width + 'px'
|
|
160
|
-
};
|
|
161
|
-
} else {
|
|
162
|
-
_dissection_node_styles = {
|
|
163
|
-
left: _outline_bottom_position_left,
|
|
164
|
-
top: _outline_bottom_position_top
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
} else {
|
|
168
|
-
if (_area.indexOf('full') !== -1) {
|
|
169
|
-
_dissection_node_styles = {
|
|
170
|
-
left: _el_offset_left + _el_rect.width + 'px',
|
|
171
|
-
top: _el_offset_top + 'px',
|
|
172
|
-
height: _el_rect.height + 'px'
|
|
173
|
-
};
|
|
174
|
-
} else if (_area.indexOf('enclose') !== -1) {
|
|
175
|
-
_dissection_node_styles = {
|
|
176
|
-
left: _el_offset_left + _el_rect.width + 'px',
|
|
177
|
-
top: _el_offset_top + -1 + 'px',
|
|
178
|
-
height: _el_rect.height + 'px',
|
|
179
|
-
width: _el_rect.width + 'px'
|
|
180
|
-
};
|
|
181
|
-
} else {
|
|
182
|
-
_dissection_node_styles = {
|
|
183
|
-
left: _outline_left_position_left,
|
|
184
|
-
top: _outline_left_position_top
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
} else {
|
|
189
|
-
if (_area.indexOf('full') !== -1) {
|
|
190
|
-
_dissection_node_styles = {
|
|
191
|
-
left: _el_offset_left - 8 + 'px',
|
|
192
|
-
top: _el_offset_top + -1 + 'px',
|
|
193
|
-
height: _el_rect.height + 'px'
|
|
194
|
-
};
|
|
195
|
-
} else if (_area.indexOf('enclose') !== -1) {
|
|
196
|
-
_dissection_node_styles = {
|
|
197
|
-
left: _el_offset_left - 1 + 'px',
|
|
198
|
-
top: _el_offset_top + -1 + 'px',
|
|
199
|
-
height: _el_rect.height + 'px',
|
|
200
|
-
width: _el_rect.width + 'px'
|
|
201
|
-
};
|
|
202
|
-
} else {
|
|
203
|
-
_dissection_node_styles = {
|
|
204
|
-
left: _outline_left_position_left,
|
|
205
|
-
top: _outline_left_position_top
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
styles.add(_dissection_node, _dissection_node_styles);
|
|
211
|
-
};
|
package/src/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
import * as __node from './lib/node';
|
|
5
|
-
import * as __spacing from './spec';
|
|
6
|
-
import * as __dissect from './dissect';
|
|
7
|
-
import * as __measure from './measure';
|
|
8
|
-
import * as __typography from './typography';
|
|
9
|
-
import * as __browser from './browser';
|
|
10
|
-
|
|
11
|
-
const speccer = () => {
|
|
12
|
-
__node.removeAll('.speccer');
|
|
13
|
-
__node.removeAll('.dissection');
|
|
14
|
-
|
|
15
|
-
const _els_to_be_specced = document.querySelectorAll('[data-speccer],[data-speccer] *:not(td)');
|
|
16
|
-
const _els_to_be_measured = document.querySelectorAll('[data-speccer-measure]');
|
|
17
|
-
const _els_to_be_typography_specced = document.querySelectorAll('[data-speccer-typography]');
|
|
18
|
-
const _els_to_be_dissected = document.querySelectorAll('[data-anatomy-section] [data-anatomy]');
|
|
19
|
-
|
|
20
|
-
_els_to_be_specced.forEach(__spacing.element);
|
|
21
|
-
_els_to_be_measured.forEach(__measure.element);
|
|
22
|
-
_els_to_be_typography_specced.forEach(__typography.element);
|
|
23
|
-
_els_to_be_dissected.forEach(__dissect.element);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const spacing = __spacing;
|
|
27
|
-
|
|
28
|
-
export const dissect = __dissect;
|
|
29
|
-
|
|
30
|
-
export const measure = __measure;
|
|
31
|
-
|
|
32
|
-
export const typography = __typography;
|
|
33
|
-
|
|
34
|
-
export default speccer;
|
|
35
|
-
|
|
36
|
-
__browser.activate(speccer);
|
package/src/lib/attributes.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
export const set = (el, attrs) => {
|
|
5
|
-
if (!el) return;
|
|
6
|
-
if (!attrs || (attrs && attrs.length === 0)) return;
|
|
7
|
-
Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]));
|
|
8
|
-
};
|
|
9
|
-
export const remove = (el, attrs) => {
|
|
10
|
-
if (!el) return;
|
|
11
|
-
if (!attrs || (attrs && attrs.length === 0)) return;
|
|
12
|
-
Object.keys(attrs).forEach(key => el.removeAttribute(key));
|
|
13
|
-
};
|
package/src/lib/classnames.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
export const set = (el, cls, avoid = 'noop') => {
|
|
5
|
-
if (!el) return;
|
|
6
|
-
if (!cls || (cls && cls.length === 0)) return;
|
|
7
|
-
cls
|
|
8
|
-
.trim()
|
|
9
|
-
.split(' ')
|
|
10
|
-
.filter(cl => cl !== avoid)
|
|
11
|
-
.forEach(cl => el.classList.add(cl));
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const toggle = (el, cls, avoid = 'noop') => {
|
|
15
|
-
if (!el) return;
|
|
16
|
-
if (!cls || (cls && cls.length === 0)) return;
|
|
17
|
-
cls
|
|
18
|
-
.trim()
|
|
19
|
-
.split(' ')
|
|
20
|
-
.filter(cl => cl !== avoid)
|
|
21
|
-
.forEach(cl => el.classList.toggle(cl));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const remove = (el, cls, avoid = 'noop') => {
|
|
25
|
-
if (!el) return;
|
|
26
|
-
if (!cls || (cls && cls.length === 0)) return;
|
|
27
|
-
cls
|
|
28
|
-
.trim()
|
|
29
|
-
.split(' ')
|
|
30
|
-
.filter(cl => cl !== avoid)
|
|
31
|
-
.forEach(cl => el.classList.remove(cl));
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const cx = (cls, cls_obj) =>
|
|
35
|
-
`${cls} ${Object.keys(cls_obj)
|
|
36
|
-
.filter(classname => cls_obj[classname])
|
|
37
|
-
.join(' ')}`.trim();
|
package/src/lib/constants.js
DELETED
package/src/lib/css.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
export const getNumberValue = value => parseInt(value, 10);
|
|
5
|
-
|
|
6
|
-
export const normalizeNumberValue = value => {
|
|
7
|
-
const _value = parseFloat(value);
|
|
8
|
-
return (_value >= 0 && _value < 1) || (_value <= 0 && _value > -1) ? 0 : _value;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const getSpacing = style => {
|
|
12
|
-
const { marginTop, marginBottom, marginLeft, marginRight, paddingTop, paddingBottom, paddingLeft, paddingRight } =
|
|
13
|
-
style;
|
|
14
|
-
return {
|
|
15
|
-
marginTop,
|
|
16
|
-
marginBottom,
|
|
17
|
-
marginLeft,
|
|
18
|
-
marginRight,
|
|
19
|
-
paddingTop,
|
|
20
|
-
paddingBottom,
|
|
21
|
-
paddingLeft,
|
|
22
|
-
paddingRight
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const getTypography = style => {
|
|
27
|
-
const { lineHeight, letterSpacing, fontFamily, fontSize, fontStyle, fontVariationSettings, fontWeight } = style;
|
|
28
|
-
return {
|
|
29
|
-
lineHeight,
|
|
30
|
-
letterSpacing,
|
|
31
|
-
fontFamily,
|
|
32
|
-
fontSize,
|
|
33
|
-
fontStyle,
|
|
34
|
-
fontVariationSettings,
|
|
35
|
-
fontWeight
|
|
36
|
-
};
|
|
37
|
-
};
|
package/src/lib/debounce.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
export const waitForFrame = () => new Promise(requestAnimationFrame);
|
|
5
|
-
|
|
6
|
-
const debounce = function (func, wait, immediate) {
|
|
7
|
-
var timeout;
|
|
8
|
-
return function () {
|
|
9
|
-
var context = this,
|
|
10
|
-
args = arguments;
|
|
11
|
-
var later = function () {
|
|
12
|
-
timeout = null;
|
|
13
|
-
if (!immediate) func.apply(context, args);
|
|
14
|
-
};
|
|
15
|
-
var callNow = immediate && !timeout;
|
|
16
|
-
clearTimeout(timeout);
|
|
17
|
-
timeout = setTimeout(later, wait);
|
|
18
|
-
if (callNow) func.apply(context, args);
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default debounce;
|
package/src/lib/node.js
DELETED
package/src/lib/number.js
DELETED
package/src/lib/resize.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
import debounce from './debounce';
|
|
5
|
-
|
|
6
|
-
export const activate = speccer => {
|
|
7
|
-
const speccerEventFunc = debounce(() => {
|
|
8
|
-
speccer();
|
|
9
|
-
}, 300);
|
|
10
|
-
|
|
11
|
-
window.removeEventListener('resize', speccerEventFunc);
|
|
12
|
-
window.addEventListener('resize', speccerEventFunc);
|
|
13
|
-
};
|
package/src/lib/styles.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
import { waitForFrame } from './debounce';
|
|
4
|
-
|
|
5
|
-
export const add = async (el, styles) => {
|
|
6
|
-
if (!el) return;
|
|
7
|
-
if (
|
|
8
|
-
!styles ||
|
|
9
|
-
(styles && styles.length === 0 && styles.constructor === String) ||
|
|
10
|
-
(styles && styles.length === 0 && styles.constructor === Array) ||
|
|
11
|
-
(styles && Object.keys(styles).length === 0 && styles.constructor === Object)
|
|
12
|
-
) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
await waitForFrame();
|
|
17
|
-
if (typeof styles === 'string' || Array.isArray(styles)) {
|
|
18
|
-
styles.forEach(style => (el.style[style.key] = style.value));
|
|
19
|
-
} else {
|
|
20
|
-
Object.keys(styles).forEach(key => (el.style[key] = styles[key]));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const get = async el => {
|
|
25
|
-
await waitForFrame();
|
|
26
|
-
return window.getComputedStyle ? getComputedStyle(el, null) : el.currentStyle;
|
|
27
|
-
};
|
package/src/measure.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
import * as classnames from './lib/classnames';
|
|
5
|
-
import * as styles from './lib/styles';
|
|
6
|
-
import * as node from './lib/node';
|
|
7
|
-
|
|
8
|
-
import { SPECCER_TAGS_TO_AVOID } from './lib/constants';
|
|
9
|
-
|
|
10
|
-
const create = (text = '', area = '', tag = 'span') => {
|
|
11
|
-
const _el = document.createElement(tag);
|
|
12
|
-
|
|
13
|
-
_el.setAttribute('title', text + 'px');
|
|
14
|
-
_el.setAttribute('data-measure', parseInt(text, 10) + 'px');
|
|
15
|
-
|
|
16
|
-
classnames.set(_el, `ph speccer measure ${area}`);
|
|
17
|
-
|
|
18
|
-
return _el;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const element = (el) => {
|
|
22
|
-
if (!el) return;
|
|
23
|
-
|
|
24
|
-
const _el_rect = el.getBoundingClientRect();
|
|
25
|
-
const _area = el.getAttribute('data-speccer-measure');
|
|
26
|
-
|
|
27
|
-
if (_area === '') {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const _el_offset_top = el.offsetTop;
|
|
32
|
-
const _el_offset_left = el.offsetLeft;
|
|
33
|
-
|
|
34
|
-
if (_area.indexOf('width') !== -1) {
|
|
35
|
-
if (_area.indexOf('bottom') !== -1) {
|
|
36
|
-
const _measure_node = create(_el_rect.width, 'width bottom');
|
|
37
|
-
|
|
38
|
-
if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
|
|
39
|
-
node.after(el.closest('table'), _measure_node);
|
|
40
|
-
} else {
|
|
41
|
-
node.after(el, _measure_node);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
styles.add(_measure_node, {
|
|
45
|
-
left: _el_offset_left + 'px',
|
|
46
|
-
top: _el_offset_top + _el_rect.height + 1 + 'px',
|
|
47
|
-
width: _el_rect.width + 'px'
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
const _measure_node = create(_el_rect.width, 'width top');
|
|
51
|
-
|
|
52
|
-
if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
|
|
53
|
-
node.after(el.closest('table'), _measure_node);
|
|
54
|
-
} else {
|
|
55
|
-
node.after(el, _measure_node);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const _measure_node_rect = _measure_node.getBoundingClientRect();
|
|
59
|
-
|
|
60
|
-
styles.add(_measure_node, {
|
|
61
|
-
left: _el_offset_left + 'px',
|
|
62
|
-
top: _el_offset_top - _measure_node_rect.height + 1 + 'px',
|
|
63
|
-
width: _el_rect.width + 'px'
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
} else if (_area.indexOf('height') !== -1) {
|
|
67
|
-
if (_area.indexOf('right') !== -1) {
|
|
68
|
-
const _measure_node = create(_el_rect.height, 'height right');
|
|
69
|
-
|
|
70
|
-
if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
|
|
71
|
-
node.after(el.closest('table'), _measure_node);
|
|
72
|
-
} else {
|
|
73
|
-
node.after(el, _measure_node);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
styles.add(_measure_node, {
|
|
77
|
-
left: _el_offset_left + _el_rect.width + 'px',
|
|
78
|
-
top: _el_offset_top + 'px',
|
|
79
|
-
height: _el_rect.height + 'px'
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
const _measure_node = create(_el_rect.height, 'height left');
|
|
83
|
-
|
|
84
|
-
if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
|
|
85
|
-
node.after(el.closest('table'), _measure_node);
|
|
86
|
-
} else {
|
|
87
|
-
node.after(el, _measure_node);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const _measure_node_rect = _measure_node.getBoundingClientRect();
|
|
91
|
-
|
|
92
|
-
styles.add(_measure_node, {
|
|
93
|
-
left: _el_offset_left - _measure_node_rect.width + 'px',
|
|
94
|
-
top: _el_offset_top + 'px',
|
|
95
|
-
height: _el_rect.height + 'px'
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|