Jump to content
Search Community

Create basic "famous" image reveal "mask" effect (from top to bottom)- how to?

Ezra Siton test
Moderator Tag

Go to solution Solved by AsKadir,

Recommended Posts

my codepen not working well (The image with distortion). 

 

https://www.loom.com/share/36a7900c2e084d49a9dc02875f223189

 

I saw this effect a lot of times (But its hard to inspect this effect) - (scroll down to team images)

https://www.yaroflasher.com/about/

 

Related issue (I do not want Solution by `absolute` position).

 

Any codepen -or- basic example of the trick behind. 

 

Thanks. 

See the Pen eYJOWjg by ezra_siton (@ezra_siton) on CodePen

Link to comment
Share on other sites

Hi and welcome to the forums.

 

A couple things:

 

I'd recommend using the new GSAP 3 syntax.

You also have a typo in your CSS:

 ovefrlow: hidden;

That being said, animating the scale is probably not what you want here. I'd just set the height of the wrapper to 0 and then use gsap to animate to height: "auto" (That's new in GSAP 3)

 

See the Pen 728d724d9ea411b7bf68889e13b02035 by PointC (@PointC) on CodePen

 

Hopefully that helps. Happy tweening.

:)

 

 

  • Like 3
Link to comment
Share on other sites

Thanks. This is the output i want. 

 

Any idea how to get the same effect but without `height`? (beacuse this change the box-model of my page). 

 

See her (The "hello world" move up and down) - in my reference (https://www.yaroflasher.com/about/) only the image clip.

 

I find a "middle" solution by extra overlay div (Less clean) - codepen example:

 

See the Pen gOPYRKP by ezra_siton (@ezra_siton) on CodePen

Link to comment
Share on other sites

17 minutes ago, Ezra Siton said:

Any idea how to get the same effect but without `height`? (beacuse this change the box-model of my page). 

You could make the image a background image with fixed sizing instead. 

 

Or you could use GSAP to set the height of a container to the height of the content and then animate the content's height. After the animation is done, remove the set height on the container.

  • Like 1
Link to comment
Share on other sites

Yeah, there's a bunch of ways to achieve this effect. I'd recommend Zach's idea. You could also use a div the same color as the background to cover the image and animate the scale of that div. You could also put the image into a SVG and use a mask or clip-path. All kinds of options available to you.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

11 minutes ago, Trapti said:

This is one way but with additional element. 

Your function creates a bunch of conflicting tweens there. I think you meant to create it outside of the mouseover listener and control it inside of the listener? I write more extensively about how to do that in my article on animating efficiently. Also it's best to use .addEventListener() instead of a direct onmouseover like that because there's a possibility for things to get overwritten if someone has multiple listeners of the same type on an element.

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