Created
September 27, 2018 12:10
-
-
Save patrickposner/26dbc71a5a19ae9521e07085ec56071a to your computer and use it in GitHub Desktop.
crazy live sizing with jquery on load / on viewport / on resize!
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 topbar for demo */ | |
| add_action( 'wp_footer', 'atomion_fix_topbar' ); | |
| function atomion_fix_topbar() { | |
| ?> | |
| <script> | |
| jQuery(document).ready(function( $ ) { | |
| var resizeTimer; | |
| if ( $( '.demo_store' ).length ) { | |
| var width = $(window).width(); | |
| if ( width >= 1100 ) { | |
| $( '.site' ).css('margin-top', '85px'); | |
| } else if( width < 1100 && width > 650 ) { | |
| $( '.site' ).css('margin-top', '96px'); | |
| } else if( width < 650 ) { | |
| $( '.site' ).css('margin-top', '133px'); | |
| } | |
| } | |
| $(window).on('resize', function(e) { | |
| clearTimeout(resizeTimer); | |
| resizeTimer = setTimeout(function() { | |
| if ( $( '.demo_store' ).length ) { | |
| var width = $(window).width(); | |
| if ( width >= 1100 ) { | |
| $( '.site' ).css('margin-top', '85px'); | |
| } else if( width < 1100 && width > 650 ) { | |
| $( '.site' ).css('margin-top', '96px'); | |
| } else if( width < 650 ) { | |
| $( '.site' ).css('margin-top', '133px'); | |
| } | |
| } | |
| }, 250); | |
| }); | |
| $('.woocommerce-store-notice__dismiss-link').on('click', function() { | |
| $( '.site' ).css('margin-top', '0px'); | |
| }); | |
| }); | |
| </script> | |
| <?php | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment