Jump to content
Search Community

CSS mask animation using gsap

sarthak950 test
Moderator Tag

Recommended Posts

Hi,

 

On top of Mitchel's great suggestion and resources, a further inspection of the site reveals that two images are being used, one as a backgound and another as a mask:

.promoListParallax:nth-of-type(odd) .promo {
    -webkit-mask: url(data:image/png;base64,...;
    mask: url(data:image/png;base64,...;
    -webkit-mask-size: 1846px 3200px;
    mask-size: 1846px 3200px;
    -webkit-mask-repeat: repeat-x;
    mask-repeat: repeat-x;
    -webkit-mask-position: top center;
    mask-position: top center;
}

So that's just creating a simple mask on elements with fixed position nothing more.

 

Happy Tweening!

Link to comment
Share on other sites

@Rodrigo Thanks for yr advice i was able to create the mask with the background but not able to animate it

slide {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
   mask-image: url("/img/masks/mask1.png");
  mask-position: top center;

  display: flex;
  justify-content: center;
  align-items: center;


}



the main bg is given sapretly for each slide  ( #slide_1 , #slide_2 )
 

<body id="body">
  <section class="slide" id="slide_1">
    <h1 class="Center_heading">This is Cool</h1>
  </section>

  <section class="slide" id="slide_2">
      <h1 id="translate" class="Center_heading">This is Cool</h1>
  </section>

  <section class="slide" id="slide_3">
    <h1 class="Center_heading">This is Cool</h1>
  </section>

  <section class="slide" id="slide_4">
    <h1 class="Center_heading">This is Cool</h1>
  </section>

  <section class="slide" id="slide_5">
    <h1 class="Center_heading">This is Cool</h1>
  </section>

  <section class="slide" id="slide_6">
    <h1 class="Center_heading">This is Cool</h1>
  </section>


  <script type="module" src="./js/animation.js"></script>
</body>

 

 

Link to comment
Share on other sites

@Rodrigo I think i was not able to communicate properly

See the Pen MWxrmyP by Sarthak_sharma_950 (@Sarthak_sharma_950) on CodePen



 now i make the mask to work
here i have 4 sections and a container 4 section have a position of absolute and the container is positioned relative
 

i have placed mask on all 4 of the sections named (slide)

as through the property of the mask that it make some portion of the container transparent
i want a curtain like effect such that the mask goes up and hide its respective container and then the other and then the other as per as the website
https://www.ubisoft.com/en-gb/game/far-cry/far-cry-6
 i hope this is an accurate description
Thanks.

Link to comment
Share on other sites

I don't get it, that is what it is doing right? The content is all the same, so it is hard to see hat is going on. Also please read this post I've linked in the first response of this topic! 

In your CSS you have the following line, which is not correct All numbers should be prefixed with % sign 

//  bad! 
 clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);

//  good 
 clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);

 

See the Pen VwRQLvw?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen

Link to comment
Share on other sites

Hi,

 

I think that you're asking us to re-create the effect from the website you linked in your first post in this thread. Unfortunately that's a bit beyond the scope of these free forums since we don't have the time resources to create that for our users.

 

For what I remember in the site you posted every single slide has the mask applied to it, not just one and they're not using clip path but moving the elements.

 

Maybe these demos can help you getting started:

See the Pen ZEvGYxE by GreenSock (@GreenSock) on CodePen

 

See the Pen eYPKNPm by GreenSock (@GreenSock) on CodePen

 

Happy Tweening!

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