Created
January 27, 2020 06:09
-
-
Save ivan-kalachikov/e9121348779ec252fc504d24b0a40d6f to your computer and use it in GitHub Desktop.
Fix woo scroll to notice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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