Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
roughRabbit

fade up if < Xpx , fade down if > Xpx

Recommended Posts

This works for my first button but the next ones fade up - but if I scroll back up only the first one disappears; the next remains.

 

 $(window).scroll(function() {
            if ($(this).scrollTop() > 400) {
                TweenLite.to("#dellie", .5, {
                    opacity: 1,
                    display: "block",
                    ease: Back.easeOut
                });
            } else {
                TweenLite.to("#dellie", .5, {
                    opacity: 0,
                    display: "none",
                    ease: Back.easeOut
                });
            }
             });
 
 
        /*#dellie1*/
        $(window).scroll(function() {
            if ($(this).scrollTop() > 800) {
                TweenLite.to("#dellie1", .5, {
                    opacity: 1,
                    display: "block",
                    ease: Back.easeOut
                });
            } else {
                TweenLite.to(".#dellie1", .5, {
                    opacity: 0,
                    display: "none",
                    ease: Back.easeOut
                });
            }
             });
 
I tried naming the functions differently, but that didn't seem to work.
 

 

I've made a codepen at

See the Pen Kvkdf by anon (@anon) on CodePen

- but don't know how to make  the screen  big enough to scroll and thus show the animation...

Link to comment
Share on other sites

Hi and thanks for providing the codepen, it's always very helpful!!.

 

Just a syntax error, you're creating a class-ID selector here:

 

TweenLite.to(".#dellie1",.5, {opacity: 0,display: "none",ease: Back.easeOut});

 

That's throwing an error. If you change your code to this:

TweenLite.to("#dellie1", .5, {
                    opacity: 0,
                    display: "none",
                    ease: Back.easeOut
                });

It works as expected.

 

Rodrigo.

  • Like 1
Link to comment
Share on other sites

Duuh!  Thanks, I  was

pulling my hair out...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×