Last active
October 2, 2019 11:23
-
-
Save beaverbuilder/b1dd93b516208cc8b0a0f9eebfa890ba to your computer and use it in GitHub Desktop.
This snippet is used in the following knowledge base article – https://kb.wpbeaverbuilder.com/article/121-smooth-scrolling-links
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
| http://example.com/#my-unique-id |
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
| <a id="my-div"></a> | |
| <div> | |
| <p>I want to link to this spot.</p> | |
| </div> |
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
| <a href="#my-div" class="fl-scroll-link">Click Here</a> |
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
| jQuery( function(){ | |
| if ( 'undefined' != typeof FLBuilderLayoutConfig ) { | |
| FLBuilderLayoutConfig.anchorLinkAnimations.duration = 1000; | |
| FLBuilderLayoutConfig.anchorLinkAnimations.easing = 'swing'; | |
| FLBuilderLayoutConfig.anchorLinkAnimations.offset = 100; | |
| } | |
| } ); |
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
| jQuery( function($){ | |
| var win = $( window ); | |
| function bbScroll(){ | |
| if ( 'undefined' != typeof FLBuilderLayoutConfig ) { | |
| var offset = 70; | |
| 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 ); | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment