I want the scrollup function to execute after the animation completes. I keep getting random occurrences of the mobileNavclick function stopping almost imediatly after its fired.
This works fine everywhere expect on IOS mobile device
//Click Event for Mobile Nav
$("#navContainer ul li a").on('click',function () {
mobileNavClick();
checkSize();
//scrollUp();
});
$("#menu").on('click',function (){
mobileNavClick();
checkSize();
});
//Mobile Nav Function
function mobileNavClick() {
var mobileMatch = window.matchMedia('(max-width: 600px)');
var nav = $('#navContainer');
var navFoot = $('#navFooter');
var navLeftCSS = nav.css('left');
if (mobileMatch.matches) {
animateNav();
}
else {
animateNavRight();
}
function animateNav() {
var navWindowWidth = '-' + $(window).width();
if ($('#navContainer').css('left') == '0px') {
nav.animate ({left: navWindowWidth});
navFoot.animate ({left: navWindowWidth});
}
}
function animateNavRight() {
var navWindowWidth = $(window).width();
if ($('#navContainer').css('left') == navWindowWidth) {
nav.animate ({right: navWindowWidth});
navFoot.animate ({right: navWindowWidth});
}
}
}
//Return Scroll to 0px
function scrollUp() {
var wrapperScrollPosition = $('#navContainer').scrollTop();
var mobileMatch = window.matchMedia('(max-width: 600px)');
$('#wrapper').scrollTop(wrapperScrollPosition);
//If on mobile device body scrolls to 0
if (mobileMatch.matches) {
$('body').scrollTop('0');
}
}
Aucun commentaire:
Enregistrer un commentaire