JavaScript 'clip-mask' equivalent on scroll (GSAP and ScrollMagic available)

900 views Asked by At

The question

Is there a way to fade contents out on a gradient similar to clip-mask using JavaScript or jQuery?

The problem

I've got a fixed header with a transparent background, and a '.png' logo with transparent pieces. I have semi-transparent elements which scroll vertically up the page, and thus below the header and logo.

When things scroll under the logo they show through and everything looks pretty bad.

The proposed solution

We'd like to fade out content above a certain point (the bottom of the header). We're using ScrollMagic with GSAP to animate elements as they scroll which causes conflicts with clip-path and other CSS fixes, so I am looking for a JavaScript/jQuery fix most likely.

enter image description here

Sample code

At the request of a commenter, I've created a JSFiddle which includes a few pieces.

There are two elements that should be considered: #masthead and #content. There's an area (in blue) below #masthead in which I would like #content to fade as a gradient from opacity 1 to 0.

https://jsfiddle.net/dotzak/o9hcnufe/3/

0

There are 0 answers