Skip to content

Instantly share code, notes, and snippets.

@ivan-kalachikov
Created January 27, 2020 06:09
Show Gist options
  • Save ivan-kalachikov/e9121348779ec252fc504d24b0a40d6f to your computer and use it in GitHub Desktop.
Save ivan-kalachikov/e9121348779ec252fc504d24b0a40d6f to your computer and use it in GitHub Desktop.
Fix woo scroll to notice
// Fix woo scroll to notice
add_action(
'get_footer',
static function () {
?>
<script>
jQuery( function( $ ) {
function init() {
if ( typeof $.scroll_to_notices === 'function' ) {
$.scroll_to_notices = function( $scrollElement ) {
if ( $scrollElement.length ) {
var $header = $( '.header' ),
top = 100;
if ( $header.length ) {
top += $header.height();
}
$( 'html, body' ).animate( {
scrollTop: ( $scrollElement.offset().top - top )
}, 1000 );
}
};
} else {
setTimeout( init, 500 );
}
}
init();
} );
</script>
<?php
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment