+ const wrapperBox = wrapper.getBoundingClientRect();
const items = wrapper.querySelectorAll('.block_line .item');
const points = [];
for (const item of items) {
const element = item.querySelector('.num');
const box = element.getBoundingClientRect();
points.push({
- x: box.left + box.width / 2 + scrollX,
- y: box.top + box.height / 2 + scrollY
+ x: box.left + box.width / 2 - wrapperBox.left,
+ y: box.top + box.height / 2 - wrapperBox.top
});
}
points.push({
- x: box.left + box.width / 2,
+ x: box.left + box.width / 2 + scrollX,
- y: box.top + box.height / 2
+ y: box.top + box.height / 2 + scrollY
});
const toError = (message) => ({
code: 'error',
message
});
const toInfo = (message) => ({
code: 'info',
message
});
toError('Hello'); // { code: 'error', message: 'Hello' }
toInfo('World'); // { code: 'info', message: 'World' }
Можете также добавить
margin
к.row2
. Либо выстроить более верную сетку родительского блока.