Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function($){
- /* Responsive Menu */
- $('.hide-menu').hide();
- $('#learn-now').click(function(event){
- event.preventDefault();
- if ($('.post-container').offset()) {
- $('html,body').animate({scrollTop: $('.post-container').offset().top}, 500);
- }
- });
- /* Main menu toggle and expand */
- $('#toggle-menu').click(function(){
- // Grab the menu container
- var el = $('#menu-container');
- // If the menu is currently expanded
- if(el.height() > 10)
- {
- // Shrink the menu to 1px. The 1px is to show the border
- curHeight = el.height();
- el.height(curHeight).animate({height: '1px'}, 300);
- // Toggle the menu toggle text
- $('#toggle-menu .show-menu').show();
- $('#toggle-menu .hide-menu').hide();
- }
- else
- {
- // Expand the menu to its normal height
- curHeight = el.height();
- autoHeight = el.css('height', 'auto').height();
- el.height(curHeight).animate({height: autoHeight}, 300);
- // Toggle the menu toggle text
- $('#toggle-menu .show-menu').hide();
- $('#toggle-menu .hide-menu').show();
- }
- });
- // Grab the initial window width
- var windowWidth = $(window).width();
- window.onresize = function() {
- // If the window has been resized to a mobile size from a desktop size
- if ($(window).width() < 767 && windowWidth >= 767) {
- // Update window width
- windowWidth = $(window).width();
- // Hide the menu toggle and set the menu's height to hide it
- $('#menu-container').css('height', '1px');
- $('#toggle-menu .show-menu').show();
- $('#toggle-menu .hide-menu').hide();
- }
- else if($(window).width() >= 767 && windowWidth < 767) {
- // Update window width
- windowWidth = $(window).width();
- // Reset the menu height
- $('#menu-container').css('height', 'auto');
- }
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement