Creating and Animating an SVG Mask

Ғылым және технология

Recently, I designed a site that had a curved edge at the bottom of the hero image. You've probably seen this on several sites. Nothing crazy or revolutionary here. But, in this video, I'll show you how to code it out as an SVG mask. Then, for added flair, we'll animate it.
0:00 Intro - What we're coding
0:54 jpg - pros and cons
1:29 png - pros and cons
2:07 Creating the mask in Figma
2:54 Getting the assets into CodePen
3:54 Explaining the SVG code
4:40 Turning the SVG into a mask
5:55 Introducing Green Sock
6:21 Creating a second SVG inside Figma
7:34 Brief Explanation of the DOM
8:06 Adding Green Sock to CodePen
8:56 Using MorphSVG
10:02 Using Greensock's Timeline
11:42 Greensock Easing
12:52 Making it Responsive
🔗 LINKS
+ Photo from unsplash.com
+ Codepen - codepen.io
+ Green Sock - greensock.com
+ Green Sock Plugins - greensock.com/products
+ Green Sock MorphSVG Documentation - greensock.com/docs/v3/Plugins...
+ Green Sock Timeline Documentation - greensock.com/docs/v3/GSAP/Ti...
+ Green Sock Yoyo Method - greensock.com/docs/v3/GSAP/Ti...)
+ Green Sock Easing - greensock.com/docs/v2/Easing
🤖 CODE
+ Final CodePen - codepen.io/ahaywood/pen/gOPrWOV
📚 REFERENCE
+ CSS-Tricks: Clipping and Masks in CSS - css-tricks.com/clipping-maski...
+ Scaling SVG Clipping Paths for CSS Use - meyerweb.com/eric/thoughts/201...
👉🏻 Get Updates and Exclusive content at: selfteach.me
💥 SelfTeach.me is a Zeal show: codingzeal.com

Пікірлер: 56

  • @vijayroy93
    @vijayroy932 жыл бұрын

    Never seen such easy explanation before. You just take out the complexity from the subject and make it breeze. ❤️

  • @tiangersbach
    @tiangersbach2 жыл бұрын

    wow! this is love at first sight ;) Love the way you made this excercise, explanation, and well documented tuto. You're a great speaker. Thanks!

  • @SelfTeachMe

    @SelfTeachMe

    2 жыл бұрын

    Thanks so much! 😊

  • @cassieselin983
    @cassieselin9833 ай бұрын

    Excellent explanation, thanks!

  • @friedrichsiever5964
    @friedrichsiever59643 ай бұрын

    Wonderful done. Thanks a million!

  • @GustavoBica
    @GustavoBica Жыл бұрын

    Great content! Super well explained and complete.

  • @SelfTeachMe

    @SelfTeachMe

    7 ай бұрын

    Awesome! Glad you found it helpful!

  • @lefxxwill7740
    @lefxxwill77403 жыл бұрын

    this video was so short but i learned so much! thank you

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    Love hearing that!

  • @carfox1860
    @carfox1860 Жыл бұрын

    Great video! Thanks!

  • @jonathanrojaslopez22
    @jonathanrojaslopez223 жыл бұрын

    Great video and good explanation!! Thank you!!

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    Thanks!!

  • @burmesepotato447
    @burmesepotato4473 жыл бұрын

    I have been finding ways how to tackle that wave animation. Amazing personality and tutorial ! Thank you!

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    Awesome! Glad you found it helpful!

  • @KenoldBeauplan
    @KenoldBeauplan3 жыл бұрын

    Wow! so easy! I just created something similar with position relative/absolute. It took me forever. Thank you.

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    That's awesome!! Excited for you.

  • @manurecaok
    @manurecaok2 жыл бұрын

    Just found this less than 15 minutes GEM and went along with it. You've seriously helped me a lot. THANK YOU! :D ♥

  • @SelfTeachMe

    @SelfTeachMe

    2 жыл бұрын

    Love hearing that! Glad you found it helpful

  • @manurecaok

    @manurecaok

    2 жыл бұрын

    @@SelfTeachMe Yeah! 🙌 Sorry to bother you but since we're on topic, do you have any content covering masking with lottie animations (made with Bodymovin in After Effects)? Searched all the morning but haven't found anything related to it that's as easy to understand as this was.

  • @SelfTeachMe

    @SelfTeachMe

    2 жыл бұрын

    What kind of masking are you trying to do? Use the Lottie file as a mask?

  • @manurecaok

    @manurecaok

    2 жыл бұрын

    @@SelfTeachMe Exactly; animated a path then tried to apply this tutorial. But the method fails (surely because of my lack of knowledge) because the export doesn't get me a tag with an ID that parents a tag 😅 So I kind of searched other ways of selecting from css but alas, couldn't find my answer. > I'm an animator with some html css & basic js knowledge 😅 Btw thank you for answering! Edit: grammar

  • @LuukBod

    @LuukBod

    Жыл бұрын

    @@manurecaok Have you ever found the answer to this? I'm currently facing the exact same issue!

  • @user-zi6ej2sx8c
    @user-zi6ej2sx8c2 жыл бұрын

    Damn why you don't have a millions of subscribers?? You really deserved that because content and the way you are explaining things are awesome!

  • @SelfTeachMe

    @SelfTeachMe

    2 жыл бұрын

    Thanks, I appreciate that!

  • @thewebspatialist

    @thewebspatialist

    3 ай бұрын

    My thoughts exactly...

  • @thewebspatialist
    @thewebspatialist3 ай бұрын

    You just make it all seem too easy...thank you

  • @huyvuduc791
    @huyvuduc7912 жыл бұрын

    Great video! thanks so much from JP

  • @SelfTeachMe

    @SelfTeachMe

    2 жыл бұрын

    You're welcome! Glad you liked it.

  • @suleymanbayram1639
    @suleymanbayram1639 Жыл бұрын

    when i see like you people who always be happy and energy i am always jealous you guys. :)

  • @digital360europes.r.l7
    @digital360europes.r.l73 жыл бұрын

    Great! Thank you so much!!!

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    You're welcome! Glad you liked it.

  • @marknikolsky9352
    @marknikolsky93523 жыл бұрын

    You are very cool speaker!

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    Thanks, Mark

  • @klirmio21
    @klirmio216 ай бұрын

    Holy shit this was sooooo goooooodddd goddamit

  • @SelfTeachMe

    @SelfTeachMe

    6 ай бұрын

    Glad you found it helpful!

  • @AgustinGiannastasio
    @AgustinGiannastasio2 жыл бұрын

    awesome

  • @SelfTeachMe

    @SelfTeachMe

    2 жыл бұрын

    Yeah!! Glad you enjoyed it.

  • @kevinhe8188
    @kevinhe8188 Жыл бұрын

    really inspired by your video, super good,:) And I have met a problem too, for i used a path as clip path to mask an image,the clip path is always on the top left corner of the image, yes, i can scale to let it mask whole image , but that's too big, so my question is can i re-positioning the path ? thanks

  • @Mike-jq7os
    @Mike-jq7os Жыл бұрын

    Wow

  • @amrutaparab4939
    @amrutaparab49393 ай бұрын

    Nice video. Is it possible to reverse this wave? like i want the image to be at the bottom (in the white part) and I want the part where the image is currently, to be white. Any help appreciated.

  • @dimadiv6583
    @dimadiv65832 жыл бұрын

    Дякую!

  • @alvarosuareztrabanco5400
    @alvarosuareztrabanco54002 жыл бұрын

    Hi! Thanks A LOT for this video. It really helped me. Is there a way to preserve the aspect ratio of the clip path? preserveAspectRatio in the SVG doesn't help.

  • @SelfTeachMe

    @SelfTeachMe

    2 жыл бұрын

    I'm not sure if this is exactly what you're looking for or not, but it looks like you need to preserve the aspect ratio of the image itself, not necessarily the clipPath. Take a look at this (forked) CodePen: codepen.io/ahaywood/pen/ExmBxeq The only thing I changed was the height property (CSS) on the img tag. It now scales and maintains it aspect ratio.

  • @alvarosuareztrabanco5400

    @alvarosuareztrabanco5400

    2 жыл бұрын

    @@SelfTeachMe Hi! thanks a lot for the effort you took. I was clipping a div with a background that is part of a css grid. I was defining the height of the row through grid-template-rows. It's a little very specific case and I'd be solving it by including the image itself (which as you shown preserves the aspect ratio of the svg). Thanks!

  • @AmyHaywoodDutton

    @AmyHaywoodDutton

    2 жыл бұрын

    @@alvarosuareztrabanco5400 Awesome! Glad you got it working!

  • @olegkoselev6975
    @olegkoselev69753 жыл бұрын

    Hi )) really nice tutorial )) but unfortunately morphing with clip path is not working for safari. I am using KUTE.js and its not working as well same as GSAP (at least codepen you created is not running for me). Am I missing anything or its really the case? Thanks for every advice ;)

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    Hey Oleg! It looks like there are some issues with this particular feature of Green Sock and Safari. I did a little Googling and several people have reported problems. Sorry for the trouble.

  • @barry-yo6752
    @barry-yo67523 жыл бұрын

    My logo file ,, why using

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    There are several things that might be causing this. Are you running a local server? Is your html in the same directory as your image folder?

  • @barry-yo6752

    @barry-yo6752

    3 жыл бұрын

    @@SelfTeachMe yes local server , I was save same project directory , but have crate name file is : image ,, and than saving inside , than copy this path ,that copy have past to image

  • @barry-yo6752

    @barry-yo6752

    3 жыл бұрын

    before : image="images-na.ssl-images-amazon.com/images/G/01/AmazonExports/Fuji/2020/May/Dashboard/Fuji_Dash_Electronics_1x._SY304_CB432774322_.jpg". that is ok ! after : image ="/Users/yutungcheng/project_front/Amazon/amazone-clone/image/2015Macbook.png". but appear " only free space "

  • @RDaneelOliwav
    @RDaneelOliwav3 жыл бұрын

    Thanks, very nice explanation I really dislike greensock though

  • @SelfTeachMe

    @SelfTeachMe

    3 жыл бұрын

    Thanks for the comment... any particular reason why you don't like Greensock? What's your alternative?

  • @_Greenflag_
    @_Greenflag_ Жыл бұрын

    Well you use a plugin so we don't understand how it works : /

  • @GhostsOfSparta
    @GhostsOfSparta2 жыл бұрын

    Madam! The title says Mask, but you've shown CSS "clip" ⁉ 👿

  • @SelfTeachMe

    @SelfTeachMe

    2 жыл бұрын

    Ahh, sorry for the confusion. I was thinking about a mask from a design perspective and not from a coding / implementation standpoint.

Келесі