0

here's my website I am now working on: http://pandino.pl/temp (it's a template only now). I have two questions:

1) I don't know what am I doing wrong, but animation works only in Google Chrome. The animations don't work in Internet Explorer and Firefox, I think it also won't work on mobile devices and in other browsers.

Here is the code of animation.js file:

function menuresize() {
        if (document.body.scrollTop > 0)
         $('#main-menu').stop().animate({"height": '50px'}, 100);
        else
         $('#main-menu').stop().animate({"height": '125px'}, 100);
}

function logoresize() {
        if (document.body.scrollTop > 0)
         $('#logo').stop().animate({
                height:'40px',
                width:'96px'
                }, 100);
        else
         $('#logo').stop().animate({
                width:'240px',
                height:'100px'
                }, 100);
}

function itemresize() {
        if (document.body.scrollTop > 0)
         $('.menu-item').stop().animate({
                height:'40px',
                width:'205px',
                "line-height":'40px'
                }, 100);
        else
         $('.menu-item').stop().animate({
                width:'205px',
                height:'100px',
                "line-height":'100px'
                }, 100);
}

function showservice() {
        if (document.body.scrollTop > 0)
         $('#service').stop().animate({"opacity": '1.0'}, 400);
        else
         $('#service').stop().animate({"opacity": '0.0'}, 50);
}

What I need to do to fix it?

2) I want to animate the scrolling to specified headers while clicking on menu items. I'm thinking about something like this: http://systemofadown.com

How to do that?


Thanks for all your kind answers!

  • Have you tried to debug it checking for `document.body.scrollTop` value? – A. Wolff Nov 08 '14 at 18:35
  • No, I did not. How can I do that? – Bartłomiej Musielak Nov 08 '14 at 18:47
  • You have to learn how to debug javascript using your console. Regarding your issue, i guess instead of `document.body.scrollTop` you should use `$(window).scrollTop()` jQuery's method `if ($(window).scrollTop() > 0)` FYI, anything different than 0 is truly in javascript, so just could be: `if($(window).scrollTop())` http://stackoverflow.com/questions/988363/how-can-i-debug-my-javascript-code – A. Wolff Nov 08 '14 at 18:49
  • Thank you Mr A. Wolff - that helped and now it's working on IE and Firefox. Anyway I still don't have answer for my second question. Anyone can help, please? – Bartłomiej Musielak Nov 09 '14 at 10:38

0 Answers0