February 25, 2013

Animated bars at scroll position

Question by user1375823

I created some animated bars with jquery. I’m only really just learning jQuery & javascript. It was working last night, the bars animated when at a certain scroll position but now it doesn’t work, nothing has been changed. Anyone help me out? Or is there a better way to do it than what I’m doing?

http://jsfiddle.net/FkUYf/1/

$(document).ready(function(){
    $(document).scroll(function() {
        var top = $(document).scrollTop();
        console.log(top);
        if (top > 930) $("#html, #css").animate({width:"100%"}, 2000);
        if (top > 930) $("#javascript").animate({width:"70%"}, 2000);
        if (top > 930) $("#php").animate({width:"50%"}, 2000);
        if (top > 930) $("#mysql").animate({width:"30%"}, 2000);
        if (top > 930) $("#wordpress").animate({width:"60%"}, 2000);
    });
});

Answer by Starx

You dont seem to hit that 930 margin. Its working fine with 330 margin.

http://jsfiddle.net/FkUYf/2/

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

Animated bars at scroll position

Question by user1375823

I created some animated bars with jquery. I’m only really just learning jQuery & javascript. It was working last night, the bars animated when at a certain scroll position but now it doesn’t work, nothing has been changed. Anyone help me out? Or is there a better way to do it than what I’m doing?

http://jsfiddle.net/FkUYf/1/

$(document).ready(function(){
    $(document).scroll(function() {
        var top = $(document).scrollTop();
        console.log(top);
        if (top > 930) $("#html, #css").animate({width:"100%"}, 2000);
        if (top > 930) $("#javascript").animate({width:"70%"}, 2000);
        if (top > 930) $("#php").animate({width:"50%"}, 2000);
        if (top > 930) $("#mysql").animate({width:"30%"}, 2000);
        if (top > 930) $("#wordpress").animate({width:"60%"}, 2000);
    });
});

Answer by Starx

You dont seem to hit that 930 margin. Its working fine with 330 margin.

http://jsfiddle.net/FkUYf/2/

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!