How to turn off responsive menu in touchfolio theme? - javascript

I'm replacing the existing menu in Touchfolio Wordpress theme and I'm trying to figure out how to turn off the responsiveness of the current menu.
I weeded out all associated media queries in css, but something triggers the responsive menu on the slider plugin side. I believe the breakpoint is set to 800px, but I couldn't find anything referring to this within the script.
Here's the link to the existing script from the demo site: http://dimsemenov.com/themes/touchfolio/demo/wp-content/themes/touchfolio/js/jquery.slider-pack.js

You could start by gutting the displayMobileMenu function in the theme's main.js. It looks like this:
displayMobileMenu = function() {
if(mobileMenu) {
mobileMenu.css('display', 'block').removeClass('menu-close-button');
_menusContainer.hide().css({ height : 0 });
return;
}
var headerHeight = _headerSideMenu.height();
mobileMenu = $('<a class="menu-button"><i class="menu-button-icon"></i>menu</a>');
$('.top-logo-group').after(mobileMenu);
setTimeout(function() {
var height = _menusContainer.height();
_menusContainer.hide().css({ height : 0 , top: _headerSideMenu.height()});
mobileMenu.bind('click.mobilemenu',function(e) {
e.preventDefault();
if(isMenuAnimating) {
return false;
}
mobileMenu.toggleClass('menu-close-button');
if ( _menusContainer.is(':visible') ) {
_menusContainer.animate({ height: 0 }, { duration: 300, complete: function () {
_menusContainer.hide();
}
});
} else {
_menusContainer.show().animate({ height : height }, { duration: 300 });
}
isMenuAnimating = false;
return false;
});
}, 0);
},
But could just as easily look like this:
displayMobileMenu = function() {},
There's still some more stuff altering the menu on smaller screens, but it doesn't fully collapse.

Related

Sticky Navigation not working

I'm trying to add a 'fixed' class to a menu once the scroller hits that menu. I've managed to get it working, but having problems removing the class once the user scrolls back to the top.
Here is the site I'm working on: http://www.allbyor.com/
Here's is my JS code:
$(window).bind('scroll', function () {
var menu = $('.bottom-row');
if ($(window).scrollTop() >= menu.offset().top) {
menu.addClass('menufix');
} else {
menu.removeClass('menufix');
}
});
You need to register the original value of the menu.offset().top in a variable, because once you change its class to fixed the top value will be the same as the $(window).scrollTop().
JSFiddle demo.
var menu = $('.bottom-row');
var menu_top_value = menu.offset().top;
$(window).bind('scroll', function () {
if ($(window).scrollTop() >= menu_top_value) {
menu.addClass('menufix');
} else {
menu.removeClass('menufix');
}
});

skip visible items from animating using JS

I'm using waypoints to have fadeIn animation when the user scrolled down, and it worked. But as you can see, during the onload, there's a fadeIn too for the first few visible items.
How to not to have that? since I binded all .card to way[point.
My js
$(function() {
var waypoints = $('.card').waypoint(function (direction) {
$(this).addClass("animated fadeIn");
}, {
offset: '90%'
});
});
DEMO : http://jsfiddle.net/ghx49d7x/
Not sure if its exactly what you want, but you can add a variable to indicate if the page has loaded or not and only add fadeIn if it has:
$(function () {
var pageLoaded = false;
var waypoints = $('.card').waypoint(function (direction) {
$(this).addClass("animated"
+ (pageLoaded ? " fadeIn" : ""));
}, {
offset: '90%'
});
pageLoaded = true;
});
Updated Fiddle: http://jsfiddle.net/ghx49d7x/3/

How to slide down a jQuery slideToggle when scaling a browser

I am having an issue with my slideToggle function. Once pressed it opens up the way I need it to. But when I scale the browser to test the responsive flow to the site the slideToggle still stays active instead of sliding down. I tried a few functions but nothing seems to work. Below is the scrip I am using without the code to slide down when it hits a specific screen resoultion. How would I go about fixing this issue?
$('#more').click(function () {
var open = $('header').is('.open');
$('#footerPanel')['slide' + (open ? 'Up' : 'Down')](400);
$('header').animate({
bottom: (open ? '-' : '+') + '=120' }, 400, function () {
$('header').toggleClass('open');
});
});
$('#menu').click(function () {
if ($('header').is('.open')) {
$('header')
.removeClass('open')
.animate({
'bottom': "-=120"
}, function () {
var $footer = $('.activetoggle');
if ($footer.length)
$footer
.toggleClass('activetoggle footerButton')
.text('Footer');
});
$('#footerPanel').slideUp(400);
}
});
$('.footerButton').click(function () {
var $this = $(this);
$this.toggleClass('footerButton');
if ($this.hasClass('footerButton')) {
$this.text('Footer');
} else {
$this.text('Close');
}
$(this).toggleClass('activetoggle');
});
My Code
http://jsfiddle.net/wyze/XqUp4/4/
Try if this works for you. I have added to check whether the width is 780(you can change it), when the panel to slide down. Try adding this in you fiddle and check if this works
$(window).resize(function(){ //check when window resize
if($(window).width() < 780){ // check when the window width is less than 780
if ($('header').is('.open')) {
$('header')
.removeClass('open')
.animate({
'bottom': "-=120"
});
$footer = $('.activetoggle');
if ($footer.length) {
$footer.toggleClass('activetoggle footerButton').text('Footer');
}
$('#footerPanel').slideToggle(400);
}
}
});

only want my function to take place on larger screens when it is no longer a mobile device

Im having trouble getting this to work, so obviously i'm doing something wrong... I created a fade-in hover state on the submenus of my menu, which works perfectly, but when I scale down to mobile view the effect is still relevant, which I do not want as mobile devices don't have hover state. so I rapped my function in a jquery(window).resize function but then it does not work at all.
jQuery(window).resize(function() {
var w = jQuery(window).width();
if (w <= 768 ) {
jQuery('nav.main-nav li').each(function() {
var submenu = jQuery(this).find('ul:first');
jQuery(this).hover(function() {
submenu.css({opacity: 1});
submenu.stop().css({overflow:'hidden', height:'auto', display:'none'}).fadeIn(300, function() {
jQuery(this).css({overflow:'visible', height:'auto', display: 'block'});
});
},
function() {
submenu.stop().css({overflow:'hidden', height:'auto', display:'none'}).fadeOut(300, function() {
jQuery(this).css({overflow:'hidden', display:'none'});
});
});
});
}
});
Instead of using jQuery(window).width();,
try using document.documentElement.clientWidth

Implementing .scrollTo()

I'm trying to implement the scrollTo script jquery script from http://flesler.blogspot.com/2007/10/jqueryscrollto.html but I cant figure it out because of the way my script is setup:
$(".viewproject").click(function() {
$(...).scrollTo( '#lightwrap', 2500, {easing:'elasout'} );
var id = $(this).attr("id").replace(/^.(\s+)?/, "");
var contentTobeLoaded = $("#workitem" + id).html();
$('#projectajax').animate({
opacity: '0'
}, 600, function() {
$('#projectpanel').show();
if ($('#projectajax').is(':visible')) {
$('#projectajax').html(contentTobeLoaded).delay(500).animate({
opacity: '1'
}, 500, function() {
$('#thumbnails, h3').css('border-top', '1px solid #fff');
});
}
else {
$('#projectajax').html(contentTobeLoaded).hide().slideDown(1000).delay(500).animate({
opacity: '1'
}, 500, function() {});
}
});
});
$(document).on('click', '#projectclose', function(e) {
e.preventDefault();
$("#projectpanel").slideUp('1000');
});
or http://jsfiddle.net/Rvgk9/
what im trying to do is when the image or link is clicked, i want it to scroll to the top of the website before if #projectajax is visible and also if #projectajax isnt visible.. from what I've tried it just didnt have the scrolling effect at all just snapped to the top of the page.

Categories