Jump to content
Search Community

fade up if < Xpx , fade down if > Xpx

roughRabbit test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

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

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.
×
×
  • Create New...