매번 하기 구찮으니까 좀 써놓자.
$.offset = el => {
const rect = el.getBoundingClientRect();
return {
top: rect.top + window.pageYOffset – document.documentElement.clientTop,
left: rect.left + window.pageXOffset – document.documentElement.clientLeft
};
};
const set_scroll_height = (target, container, option_height) => {
container.scrollTo(0, $.offset(target).top – option_height);
};