Last active
October 5, 2018 03:22
-
-
Save carlosonweb/78cb80369023fbc41dc0c67a5765382e to your computer and use it in GitHub Desktop.
BB Smooth Scrolling Code Tweak Loaded At the Bottom of the Page
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
/** | |
* | |
* 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