0

I'm looking to create an effect where two blocks of text slide in from the left and right as they scroll into view, and then the same blocks vanish sliding back the way they came as they leave the viewport. I need to change the opacity and the left/right value, I think, but I am having a hard time making this work.

Problems I encounter are that the effect either doesn't trigger even though I can detect that I am inside the right if/else section, or that the effect triggers endlessly.

Detecting when the page is scrolled to the right area is easily done via this function:

$(window).on('scroll', function() {
    scrollPosition = $(this).scrollTop();
    if (scrollPosition > 500 && scrollPosition < 1000) {
        //slide into view
    } else {
        //slide out of view
    }
});

I've been able to glean some insights from this previous question and this one, but I still can't find a solution that works for me.

Can anyone help?

Community
  • 1
  • 1
MikeK
  • 373
  • 1
  • 2
  • 16

0 Answers0