SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Feb 2013
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I add more classes with individual widths to this script?

    Code JavaScript:
    	$('.html').animate(
    	    {width:'90%'}, 
    	    {
    	        duration: 3000,
    	        step: function(now, fx) {
    	            if(fx.prop == 'width') {
    	                $(this).html(Math.round(now * 100) / 100 + '%');
    	            }
    	        }
    	    }        
    	);

    If i have four progress-bars width individual progress-procents that i want to do a fill-animation on, like this one above, can i add the three other bars to this script or do I have to do this script four times?

    And also, if i want to add some text before the (Math.round(now * 100) / 100 + '%'); how do I do that? Like if I want it to say "HTML 90%" instead of just "90%" as it outputs now.

    fiddle

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    You can make a generic animate function and call this for each div with a class of "progress".

    Fiddle

    Hope that helps.

  3. #3
    SitePoint Addict
    Join Date
    Feb 2013
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Hi,

    You can make a generic animate function and call this for each div with a class of "progress".

    Fiddle

    Hope that helps.
    thanks that helped=)

    If I would want this animate to be triggered one time when the element is in view for the first time how would i do this?

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by ReGGaeBOSS View Post
    If I would want this animate to be triggered one time when the element is in view for the first time how would i do this?
    This should point you in the right direction: http://remysharp.com/2009/01/26/elem...-event-plugin/

    Let me know if you have a specific question.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •