Jump to content


Gradient Filter Masking between two images

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



I have two images and want to gradient mask between these images when I move my mouse in the horizontal direction.


Similar what they have done on:




In other words: Image 1 is displayed and as I move my mouse over the image from left to right it should gradient mask out Image 1 and show Image 2 as I move the mouse to the right.


How can this be done with GSAP?


Link to comment
Share on other sites

Here's a rough concept with just the GreenSock logo: 


You could easily apply the same concept to an image that's sitting on top of another image to create that gradated transition that moves with the mouse. 


As a performance consideration, I just create a single tween that moves the mask from left to right, and then tween that tween's progress value according to how far the mouse is across the whole image. So if it's in the middle, the progress would be 0.5, for example. 


Hope that helps!

  • Like 3
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.