client/lib/scroll-into-viewport/index.js
function scrollIntoViewport( element ) {
	const elementStartY = recursivelyWalkAndSum( element, 'offsetTop', 'offsetParent' ),
		elementEndY = elementStartY + element.offsetHeight;
	if ( isInViewportRange( elementStartY, elementEndY ) ) {
		return;
	}

	try {
		window.scroll( {
			top: elementStartY,
			left: 0,
			behavior: 'smooth',
		} );
	} catch ( e ) {
		window.scrollTo( 0, elementStartY );
	}
}
function scrollIntoViewport( element ) {
	const elementStartY = recursivelyWalkAndSum( element, 'offsetTop', 'offsetParent' ),
		elementEndY = elementStartY + element.offsetHeight;
	if ( isInViewportRange( elementStartY, elementEndY ) ) {
		return;
	}

	try {
		window.scroll( {
			top: elementStartY,
			left: 0,
			behavior: 'smooth',
		} );
	} catch ( e ) {
		window.scrollTo( 0, elementStartY );
	}
}
Scroll an element into the viewport if it's not already inside the viewport
@param {HTMLElement} element