Created
June 29, 2018 12:21
-
-
Save matasarei/efa46342fd64a8a8b77bd5272412ba16 to your computer and use it in GitHub Desktop.
Fixed Bootstrap panel
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
| (() => { | |
| const panel = $('.panel-request'); | |
| const offsetTop = panel.offset().top; | |
| $(window).on('scroll resize', () => { | |
| const scrollTop = $(window).scrollTop(); | |
| if (scrollTop > offsetTop) { | |
| panel.css({ | |
| 'position': 'absolute', | |
| 'top': scrollTop - offsetTop, | |
| 'width': panel.parent().width() | |
| }); | |
| } else { | |
| panel.css({ | |
| 'position': 'inherit', | |
| 'top': 'auto', | |
| 'width': 'auto' | |
| }); | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment