SitePoint Sponsor

User Tag List

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

    fade in from bottom?

    fadein.png

    The red button on the image above, it shows when the user hover the image. ATM it just appears, no effects or anything, however, I would like it to fade and slide in from let say a position 50px under its current position. How would I do this?

    Code HTML4Strict:
    <div class="wrapper">
    <div class="overlay">
        <div class="button">BUTTON</div>
    </div>
    <img />
    </div>

    Code CSS:
    .wrapper{
    width: 50%;
    overflow: hidden;
    }
     
    img{
    width: 100%;
    }
     
    .overlay{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    }
     
    .button{
    display: block;
    width: 200px;
    height: 50px;
    margin: 0 auto;
    margin-top: 40%;
    background: red;
    }

    Thx in advance!

  2. #2
    SitePoint Addict
    Join Date
    Feb 2013
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is my code ATM: http://jsfiddle.net/eum75/21/

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

    Use animate instead of fadeIn:

    Code JavaScript:
    $("button")
      .css('opacity', 0)
      .slideUp('slow')
      .animate(
        { opacity: 1 },
        { queue: false, duration: 'slow' }
    );

    Code is untested, so may need some tweaking.

    Ref: http://stackoverflow.com/questions/5...simultaneously

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

    Use animate instead of fadeIn:

    Code JavaScript:
    $("button")
      .css('opacity', 0)
      .slideUp('slow')
      .animate(
        { opacity: 1 },
        { queue: false, duration: 'slow' }
    );

    Code is untested, so may need some tweaking.

    Ref: http://stackoverflow.com/questions/5...simultaneously
    Okey thanks, Trying it out but cant get it to work, the opacity 0 and 1 works but there is no fade/slide animation.

    http://jsfiddle.net/eum75/34/

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

    You're getting there.

    You have one syntax error in your code (use the console )
    {'opacity', 1} should be { opacity: 1 }

    Also, try replacing slideDown with slideUp and see what happens.

    Let me know how you get on.

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

    You're getting there.

    You have one syntax error in your code (use the console )
    {'opacity', 1} should be { opacity: 1 }

    Also, try replacing slideDown with slideUp and see what happens.

    Let me know how you get on.
    Thanks, working better, still not quit where i want it tho=)

    http://jsfiddle.net/eum75/42/

    Hmm here is an example of something similair of what i want to do. http://matthewcarleton.com/

    When entering the site, the text on the banner fade in from the right, I want to do that but I want it to fade in from bottom.

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

  8. #8
    SitePoint Addict
    Join Date
    Feb 2013
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    thanks (Y).

    Still got some issues do, I need it to have procentual margin-values, as the container use procentual width/height (responsive website). I changed the values in the fiddle to % values and it seem to work sometimes.
    Sometimes it works, but sometimes it just fades in, and other times it just appears with no fading or sliding at all.

    Do you know what might be the cause?

    http://jsfiddle.net/u2ZME/73/

  9. #9
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,996
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by ReGGaeBOSS View Post
    Sometimes it works, but sometimes it just fades in, and other times it just appears with no fading or sliding at all.
    It seems to occur if you hover over the div to start the animation, then move your mouse away from the div before the animation is complete.

    Change the mouseout part to this:

    Code JavaScript:
    $('.button').stop(true, true).css('margin-top', '55%').css('opacity', '0');

    and the problem should be solved.

  10. #10
    SitePoint Addict
    Join Date
    Feb 2013
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    It seems to occur if you hover over the div to start the animation, then move your mouse away from the div before the animation is complete.

    Change the mouseout part to this:

    Code JavaScript:
    $('.button').stop(true, true).css('margin-top', '55%').css('opacity', '0');

    and the problem should be solved.
    Thanks man, working like a charm!

  11. #11
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,996
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by ReGGaeBOSS View Post
    Thanks man, working like a charm!
    You're welcome
    Thanks for taking the time to report back (it makes a difference).


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
  •