src/component/intro/intro.js
function _scrollTo(scrollTo, targetElement, tooltipLayer) {
    if (!this._options.scrollToElement) return;

    if (scrollTo === 'tooltip') {
        var rect = tooltipLayer.getBoundingClientRect();
    } else {
        var rect = targetElement.element.getBoundingClientRect();
    }

    if (!_elementInViewport(targetElement.element)) {
        var winHeight = _getWinSize().height;
        var top = rect.bottom - (rect.bottom - rect.top);
        var bottom = rect.bottom - winHeight;

        // TODO (afshinm): do we need scroll padding now?
        // I have changed the scroll option and now it scrolls the window to
        // the center of the target element or tooltip.

        if (top < 0 || targetElement.element.clientHeight > winHeight) {
            window.scrollBy(
                0,
                rect.top - (winHeight / 2 - rect.height / 2) - this._options.scrollPadding
            ); // 30px padding from edge to look nice

            //Scroll down
        } else {
            window.scrollBy(
                0,
                rect.top - (winHeight / 2 - rect.height / 2) + this._options.scrollPadding
            ); // 30px padding from edge to look nice
        }
    }
}
function _scrollTo(scrollTo, targetElement, tooltipLayer) {
    if (!this._options.scrollToElement) return;

    if (scrollTo === 'tooltip') {
        var rect = tooltipLayer.getBoundingClientRect();
    } else {
        var rect = targetElement.element.getBoundingClientRect();
    }

    if (!_elementInViewport(targetElement.element)) {
        var winHeight = _getWinSize().height;
        var top = rect.bottom - (rect.bottom - rect.top);
        var bottom = rect.bottom - winHeight;

        // TODO (afshinm): do we need scroll padding now?
        // I have changed the scroll option and now it scrolls the window to
        // the center of the target element or tooltip.

        if (top < 0 || targetElement.element.clientHeight > winHeight) {
            window.scrollBy(
                0,
                rect.top - (winHeight / 2 - rect.height / 2) - this._options.scrollPadding
            ); // 30px padding from edge to look nice

            //Scroll down
        } else {
            window.scrollBy(
                0,
                rect.top - (winHeight / 2 - rect.height / 2) + this._options.scrollPadding
            ); // 30px padding from edge to look nice
        }
    }
}
function _scrollTo ( scrollTo , targetElement , tooltipLayer ) { if ( ! this . _options . scrollToElement ) return ; if ( scrollTo === 'tooltip' ) { var rect = tooltipLayer . getBoundingClientRect ( ) ; } else { var rect = targetElement . element . getBoundingClientRect ( ) ; } if ( ! _elementInViewport ( targetElement . element ) ) { var winHeight = _getWinSize ( ) . height ; var top = rect . bottom - ( rect . bottom - rect . top ) ; var bottom = rect . bottom - winHeight ; // TODO (afshinm): do we need scroll padding now? // I have changed the scroll option and now it scrolls the window to // the center of the target element or tooltip. if ( top < 0 || targetElement . element . clientHeight > winHeight ) { window . scrollBy ( 0 , rect . top - ( winHeight / 2 - rect . height / 2 ) - this . _options . scrollPadding ) ; // 30px padding from edge to look nice //Scroll down } else { window . scrollBy ( 0 , rect . top - ( winHeight / 2 - rect . height / 2 ) + this . _options . scrollPadding ) ; // 30px padding from edge to look nice } } }
To change the scroll of `window` after highlighting an element

@api private
@method _scrollTo
@param {String} scrollTo
@param {Object} targetElement
@param {Object} tooltipLayer
To change the scroll of window after highlighting an element