Jquery animation problem

Hello experts,

this is the site I develope - goo.gl/YCMS3q .

Q: Why the navigation menu on mobile devices doesn't scroll right?
* On desktops it's ok [don't look at styling on desktop- it's not done yet]

This is the JS:
$(function() {
	var nav = $('.nav');
	var navLiA = $('.nav>ul>li>a');
	var collapse = $('#collapse');
	var collapsedSpan = $('#collapse > span');

	//full-screen bg
	$(window).on('resize', function() {
	//hamburger button menu
	$(collapse).on('click', function() {
		$(collapsedSpan).toggleClass('fa-bars fa-close');
	$(navLiA).on('click', function(e) {

        var scrollAnchor = $(this).attr('href');
        var scrollPoint  = $(scrollAnchor).offset().top;

        $('html, body').animate({
            scrollTop : scrollPoint
        }, 700);

		if (collapse.is(":visible") ) {

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
What are we looking for - seems to work fine here.
Fajer39Author Commented:
Please try to click couple of time to the navigation links without refreshing on mobile devices.

IOS 8.4- Safari,- when click on contact- it scrolls to the wrong coordinates.

Android 4.3 - It's like the "final destination" of the scroll is shown right after the click(overlays the header) for like 100ms, then it disappears and then the scroll start.
EDIT: The problem from android actually happens on all devices- it was just so fast that I didn't noticed it at first
Julian HansenCommented:
Nope - seems to work fine for me scrolls to the right place every time.

Do you see the same thing happening here http://mobiletest.me/?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Fajer39Author Commented:
I tried it on the real phones, not emulators...The problem is that in chrome dev tools, everything is fine too, but on the actual device...it's not the case...it's ok on the http://mobiletest.me/ but that's not keeping me calm because my girlfriend's iphone 5 and my galaxy s4 still don't work right with this features
Julian HansenCommented:
Going to be difficult to debug then.

Try disabling different scripts on your page and see if that makes a difference.
Fajer39Author Commented:
So the problem was with the script...which was obvious to me from the beggining since it didn't work across all devices...I really don't know how you've tested it. But anyway, I've solved it myself. I found this code snippet which I edited to suit for my needs and it works like a charm:

$('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        || location.hostname == this.hostname) {

        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
           if (target.length) {
                 scrollTop: target.offset().top
            }, 1000);
            return false;

Open in new window

So I hope It helps other people as well.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fajer39Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.