Use jQuery for scrolling to element for all browsers to avoid special cases.

This commit is contained in:
Peter Fabian 2018-08-06 19:56:09 +02:00
parent 97fcc50c30
commit caa978cf2d
1 changed files with 3 additions and 12 deletions

View File

@ -66,19 +66,10 @@ jQuery( function( $ ) {
// Common scroll to element code.
$.scroll_to_notices = function( scrollElement ) {
var isSmoothScrollSupported = 'scrollBehavior' in document.documentElement.style;
if ( scrollElement.length ) {
if ( isSmoothScrollSupported ) {
scrollElement[0].scrollIntoView({
behavior: 'smooth',
block: 'center'
});
} else {
$( 'html, body' ).animate( {
scrollTop: ( scrollElement.offset().top - 100 )
}, 1000 );
}
$( 'html, body' ).animate( {
scrollTop: ( scrollElement.offset().top - 100 )
}, 1000 );
}
};
});