Да приделай всем элементам сразу:
if (!Element['scrollMe']) {
Element.prototype['scrollMe'] = function () {
window.scrollTo({
top: this.offsetFrom(document.body).top,
left: this.offsetFrom(document.body).left,
behavior: 'smooth'
});
};
}
А там уж хоть чучелком, хоть через что-то:
<div onclick="this.scrollMe()">чтототам</div>
UPD. Забыл Element.offsetFrom() написать.
Element.prototype['offsetFrom'] = function (element) {
var ret = {};
var currentBounds = this.getBoundingClientRect();
var elementBounds = element.getBoundingClientRect();
ret.top = currentBounds.top - elementBounds.top;
ret.left = currentBounds.left - elementBounds.left;
ret.bottom = currentBounds.bottom - elementBounds.bottom;
ret.right = currentBounds.right - elementBounds.right;
ret.topHeight = ret.top + currentBounds.height;
ret.leftWidth = ret.left + currentBounds.width;
return ret;
};