Skip to content

Instantly share code, notes, and snippets.

@carlosonweb
Last active October 5, 2018 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosonweb/78cb80369023fbc41dc0c67a5765382e to your computer and use it in GitHub Desktop.
Save carlosonweb/78cb80369023fbc41dc0c67a5765382e to your computer and use it in GitHub Desktop.
BB Smooth Scrolling Code Tweak Loaded At the Bottom of the Page
/**
*
* It's essentially the same code here:
* https://kb.wpbeaverbuilder.com/article/634-smooth-scrolling-tweaks-with-code
*
* I'm just using "wp_footer" action hook to load the code to the bottom of the page (see priority = 999).
* You need to change 'page-slug-here' in LINE 10 to correspond with the target page.
*
*/
add_action ( 'wp_footer', function(){
if ( !is_page( 'page-slug-here' ) ) return;
?>
<script id="bb-smoooth-scrolling">
jQuery( function($){
var win = $( window );
function bbScroll(){
if ( 'undefined' != typeof FLBuilderLayoutConfig ) {
var offset = 300;
if ( 'undefined' === typeof FLBuilderLayout ) {
return;
}
if ( FLBuilderLayout._isMobile() && win.width() < 992 ) {
offset = 0;
}
if ( $( 'body.admin-bar' ).length > 0 ) {
offset += 32;
}
FLBuilderLayoutConfig.anchorLinkAnimations.duration = 1000;
FLBuilderLayoutConfig.anchorLinkAnimations.easing = 'swing';
FLBuilderLayoutConfig.anchorLinkAnimations.offset = offset;
}
}
bbScroll();
win.on( 'resize', bbScroll );
} );
</script>
<?php
}, 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment