Use jQuery for scrolling to element for all browsers to avoid special cases.
This commit is contained in:
parent
97fcc50c30
commit
caa978cf2d
|
@ -66,19 +66,10 @@ jQuery( function( $ ) {
|
||||||
|
|
||||||
// Common scroll to element code.
|
// Common scroll to element code.
|
||||||
$.scroll_to_notices = function( scrollElement ) {
|
$.scroll_to_notices = function( scrollElement ) {
|
||||||
var isSmoothScrollSupported = 'scrollBehavior' in document.documentElement.style;
|
|
||||||
|
|
||||||
if ( scrollElement.length ) {
|
if ( scrollElement.length ) {
|
||||||
if ( isSmoothScrollSupported ) {
|
$( 'html, body' ).animate( {
|
||||||
scrollElement[0].scrollIntoView({
|
scrollTop: ( scrollElement.offset().top - 100 )
|
||||||
behavior: 'smooth',
|
}, 1000 );
|
||||||
block: 'center'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$( 'html, body' ).animate( {
|
|
||||||
scrollTop: ( scrollElement.offset().top - 100 )
|
|
||||||
}, 1000 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue