updateScroll = function(direction) {
    const obj = this;

    // Jspreadsheet Container information
    const contentRect = obj.content.getBoundingClientRect();
    const x1 = contentRect.left;
    const y1 = contentRect.top;
    const w1 = contentRect.width;
    const h1 = contentRect.height;

    // Direction Left or Up
    const reference = obj.records[obj.selectedCell[3]][obj.selectedCell[2]].element;

    // Reference
    const referenceRect = reference.getBoundingClientRect();
    const x2 = referenceRect.left;
    const y2 = referenceRect.top;
    const w2 = referenceRect.width;
    const h2 = referenceRect.height;

    let x, y;

    // Direction
    if (direction == 0 || direction == 1) {
        x = (x2 - x1) + obj.content.scrollLeft;
        y = (y2 - y1) + obj.content.scrollTop - 2;
    } else {
        x = (x2 - x1) + obj.content.scrollLeft + w2;
        y = (y2 - y1) + obj.content.scrollTop + h2;
    }

    // Top position check
    if (y > (obj.content.scrollTop + 30) && y < (obj.content.scrollTop + h1)) {
        // In the viewport
    } else {
        // Out of viewport
        if (y < obj.content.scrollTop + 30) {
            obj.content.scrollTop = y - h2;
        } else {
            obj.content.scrollTop = y - (h1 - 2);
        }
    }

    // Freeze columns?
    const freezed = getFreezeWidth.call(obj);

    // Left position check - TODO: change that to the bottom border of the element
    if (x > (obj.content.scrollLeft + freezed) && x < (obj.content.scrollLeft + w1)) {
        // In the viewport
    } else {
        // Out of viewport
        if (x < obj.content.scrollLeft + 30) {
            obj.content.scrollLeft = x;
            if (obj.content.scrollLeft < 50) {
                obj.content.scrollLeft = 0;
            }
        } else if (x < obj.content.scrollLeft + freezed) {
            obj.content.scrollLeft = x - freezed - 1;
        } else {
            obj.content.scrollLeft = x - (w1 - 20);
        }
    }
}
Update scroll position based on the selection