On-Scroll Morphing Background Shapes

A decorative website background effect where SVG shapes are morphing and transforming on scroll.

Today we’d like to share a little background effect with you. The idea is to animate a decorative SVG shape on scroll. The shape is morphing into different forms depending on the section we are currently viewing. The animations are powered by Julian Garnier’s anime.js and the scroll detection is supported by Stu Kabakoff’s scrollMonitor.js.

The inspiration for this work came from the brilliant AdCamp Dribbble shot by Michał Kociszewski.

Attention: We are using a couple of new CSS properties like CSS variables and the new CSS grid layout which won’t work in older browsers.

This demo is kindly sponsored by HelloSign API, an eSign API that provides seamless eSignatures for your app or workflow.

For drawing the SVG shapes we used Inkscape as it provides an easy way to create and copy paths directly as SVG in its practical XML Editor. It also offers some helpful SVG output options like the path string format, which comes in really handy when creating consistent path data for animations.

Tiny break: 📬 Want to stay up to date with frontend and trends in web design? Subscribe and get our Collective newsletter twice a tweek.

Besides morphing the shapes, i.e. animating from one path to another, we also transform them and change their fill color. This allows for even more diversity for the look of the formations.

When hovering over the items, you’ll also notice a little parallax effect.

MorphingBackgroundShapes_01

MorphingBackgroundShapes_02

MorphingBackgroundShapes_03

We hope you enjoy this little experiment and find it useful.

References and Credits

Manoela Ilic

Manoela is the main tinkerer at Codrops. With a background in coding and passion for all things design, she creates web experiments and keeps frontend professionals informed about the latest trends.

Stay in the loop: Get your dose of frontend twice a week

Fresh news, inspo, code demos, and UI animations—zero fluff, all quality. Make your Mondays and Thursdays creative!

Feedback 28

Comments are closed.
  1. That’s cool. Never thought about that even being possible. Amazing as usual, Mary!

  2. Wow, this is amazing! Thx for sharing! It seems to be a bit laggy in Safari compared to Chrome. Do you have an idea why?

  3. Manoela: This is amazing. I made demo2 work on weebly. Just a little problem though. My blobs don’t change colors and shapes much and they kind of lazily oscillate. It still looks nice though.

  4. Strange behavior. On iphone with safari the blobs would change color and shape if I change the phone orientation. They stay the same scrolling up and down, but they do cycle through the four of five shapes the demo shows by changing the phone position!!

  5. Hi Marry,
    As always your work is awesome, I was wondering if you can write a article about which tools and IDE’s you use !

  6. Hello there, Great work with the background effect! I was just wanting to change the distance between each of the ‘content-wrap’ divs. Just wondering if you could help me? Thanks heaps.

  7. Great work Marry, Loved the background effects. I will definitely be using them in future projects and will give credit.

  8. Nice !

    Anyone can help me to include this script Into a wordpress theme ?
    I try day after day…

  9. Hello, I love this, but I am not a developer, I work on wordpress and the divi template is there any way to do this in wordpress and with this template? Could they guide me?

  10. Amazing work as always. Just a little question, how do you make the blobs move on their own like jelly even when we are not scrolling. I have tried to implement it on codenpen – https://codepen.io/rohitgd/pen/vZyjQL?editors=1010 using Greensock’s MorphSVG plugin and jQuery to detect scroll position, but I can’t figure out how to move the blobs on their own.

    • Look at the source code on the downloadable sample. In the script section, look for ‘const shapes’. The value ‘path’ and ‘pathAlt’ should be different. It animates from the coordinates given in ‘path’ to ‘pathAlt’ back and forth that’s why it seems like it’s moving on its own.

  11. !GREAT – AWESOME!
    I would love to use that for my new website… BUT unfortunately, nothing works with IE – does exist a fall back for IE, so users can at least click on a link?

  12. LOVE THIS!
    I will definitely use it! But it doesn’t load in Firefox… Is there a reason why?
    Also, is there a way to add more than one shape at the same time?

  13. Hey, really like this, i’ve downloaded the file and started playing around with it, weirdly on all the demos I hit frank and all of background blobs disappear even from my earlier scrolling. It’s giving me back a JS error ‘Error: attribute d: Expected moveto path command (‘M’ or ‘m’), “NaNM 247.6,239.6…”.’

    This is on ‘anime.min.js:25’ I’m currently on Opera browser. Anyone have any thoughts on how to make the background morph a bit more friendly across browsers?

    • So I had the same problem, but I figured out the issue. This is what I did (by the way I just did it on the demo 3 because is what I needed, but I imagine is the same for the other demos).
      So, first of all, be sure to create the SVG document with the same size as the viewport that is used in the demo (in my case was 1400 width x 770 height). Then center your illustration, and then after you export the SVG file try to minimize it (I used this http://www.svgminify.com/). This was after observing that my d paths or polygon points were a lot longer than the originals (this tool will give you a cleaner version), also when I was testing the first demo it didn’t like path with negative values, that was created because I was just throwing my illustration in a random part of the canvas, and the canvas also was huge.
      So try to do that, hopefully, it also works for you!

  14. I’m getting this error on safari while it works in other browsers.

    Here’s the error: “SyntaxError: Unexpected identifier ‘key’. Expected either ‘in’ or ‘of’ in enumeration syntax.”

  15. Good Article. You always come up with something new. Amazing ideas you have shared with us. Thanks for Sharing. Keep posting

  16. Hi guys, I’m a newbie to front-end web design. And I’m fascinated with what you guys do here. I’d like to know how I could learn how to do stuff like that, and improve my skills as a front-end developer. Thanks

  17. Hi Mary,
    thanks a lot for such wonderful effect..
    I have a small doubt.. is there a way to use gradients and change gradients inside the svg morphs if yes can you please tell me how to use
    Please