Frontend Horse #5 - Infinite Scrolling and Slick Animations
Tags: html, css, javascript, webdev
Published: 2020-06-26 15:51:33

_This is an issue from the newsletter Frontend Horse. This was originally published on June 25th, 2020. Visit [Frontend.Horse](https://frontend.horse) to subscribe and find more issues._

---

Oh, howdy, I didn’t see you there! I was just saddling up to hit the trail. Care to ride with us? There’s a lot to learn in this issue, so I hope you packed a lunch.

This week we’re taking a close look at a beautiful portfolio site menu and a CodePen demo for an impressive carousel library!

---

### SITE SHOWCASE
## Marvin Schwaibold
![A page for Isle of Dogs, on the portfolio site of Marvin Schwaibold](https://dev-to-uploads.s3.amazonaws.com/i/wup6pk47rk736woqhrsb.png)

I can’t say enough about [the incredible portfolio site of Marvin Schwaibold](https://www.marvinschwaibold.com/). I love the font choice and elegant design, the way every element has its own transition when you go to a new page, and the perfect execution.

I spoke with Jesper Vos, the site’s developer, to learn some of his techniques. Jesper was kind enough to show us all the magic that went into making the [Projects Page](https://www.marvinschwaibold.com/projects).

![The sideways list of portfolio pieces](https://dev-to-uploads.s3.amazonaws.com/i/w1xc8lzxfz5ul98c5phs.png)

#### Technique: Infinite Scroll
The page _seems_ simple: a list of projects flipped on its side so that as you scroll down, they move from right to left. There are 15 projects on display here, and yet you can scroll forever. The trick here is to double the list to make 30 items. Then, when the user is about to scroll to the end, you instantly snap them back to the start.

It’s hard to wrap your head around, so here’s how you can visualize it. With your dev tools, change the text on one of the items to something noticeable like “HOOOOOOWDY.” Then, start scrolling and notice that at a certain point, it ‘fixes’ itself. Keep scrolling and watch your “HOOOOOOWDY” come right back around.

It’s a great trick you can apply to anything to make it appear infinite. I used it  on a couple of [CodePens](https://codepen.io/a-trost/pen/pXzbbq) myself!

#### Technique: Image Layering
A few changes happen when you hover your mouse over a portfolio piece in the list. Let’s use the portfolio piece “Death of Stalin” as an example.

For one, the background turns red to match the “Death of Stalin” page. That way if you click through, that part of the page transition has already happened.

![A hover effect where the background changes from tan to red](https://dev-to-uploads.s3.amazonaws.com/i/l3ebvq6r2sf82hju4uzt.png)

An image from the movie appears _behind_ the “Death of Stalin” text but _in front_ of the other items. When hovered, the “Death of Stalin” list item gets an `active` class, which gives it `z-index:2;`. The corresponding image becomes visible and gets a `z-index:1;`, and everything else keeps the default `z-index` of `0`. The other items also drop a bit in opacity, letting you focus on the current element.

#### Technique: Image Physics
My favorite part of this page is the tiny bit of rotation you’ll get on the images based on your mouse’s velocity. Jesper explains that “springy easing gives them that little physical/tactile feeling.” I highly recommend you open your dev tools as you mouse around the page to see the transforms taking place in real-time.

The site was developed by [Jesper Vos](https://twitter.com/jesper_vos), designed by [@MSchwaibold](https://twitter.com/MSchwaibold) and motion by [@YaelBienenstock](https://twitter.com/YaelBienenstock). This same team won the [Awwwards Site of the Month](https://www.awwwards.com/madeleine-dalla-wins-site-of-the-month-march-2020.html) for March 2020 for their work on [Madeleine Dalla](https://www.madeleinedalla.com/).  That’s another must-see site with impeccable design and animations!

The entire site has wonderful page-transitions on the images and text. If you’re interested in learning that technique, this [Codrops article](https://tympanus.net/codrops/2020/06/17/making-stagger-reveal-animations-for-text/) seems like a great place to start.

[Check it out ->](https://www.marvinschwaibold.com/)

---
### CODEPEN
## Mustache Guy
[This CodePen](https://codepen.io/team/wtc/pen/mNdgxd) by [We The Collective](https://www.wethecollective.com/) is a fun demo to show off [their new carousel library](https://github.com/wethegit/wtc-controller-carousel). Since Carousels & Horses go together like Peanut Butter & Jelly, we just _had_ to check it out.

{% codepen https://codepen.io/team/wtc/pen/mNdgxd %}

I’ve gotta start with the excellent illustrations. The hairstyle slideshow feels like looking through old photos of your dad over the decades.

“It was the 60’s!”
“There’s no excuse, Dad. No excuse.”

The illustrator, [Ariel Hitchcock](https://twitter.com/arielsaysmaybe), did a fantastic job, especially on the hover-state illustrations. I recommend hovering over each Mustache Guy to find his hidden attire.

The Mustache Guys are all SVG, brought to life with CSS animations. The carousel uses their new library, `wtc-controller-carousel`, as well as another of their packages, `wtc-tween`. I reached out to [Liam](https://twitter.com/liamegan) of We the Collective to discover why his team decided to write their own carousel library.

> The carousel library is meant to fill a really specific requirement, which is to have a responsive, infinite carousel of elements. There are other libraries that can accomplish this, but they clock in at huge file sizes. We built this library because we’d been doing this from scratch over and over again. We also have a number of other libraries that we built to do different things (like galleries) that are lean, simple-to-use, and fully accessible.

I couldn’t agree more with his reason to make a library. My hatred for doing the same task, again and again, is the entire reason I picked up programming. His team has done the same thing multiple times, so now they save time and we all benefit from it being open sourced.

One of my favorite parts of the pen is when you click the “Accelerate” button. The carousel starts speeding up until it’s a blur, while the sides shrink down. It then switches to one Mustache Guy at a time, and the whole effect is so good, I had to know how it worked.

> This library has a property called `speed`, which alters the speed at which it runs. We just tween that from the base speed to the speed at which this slideshow effect would happen while at the same time tweening down the width to a single element.

For the tweening, the developer, [Marlon Marcello](https://twitter.com/marlonmarcello), is using another custom library, `wtc-tween`. There’s something to be said for having your own libraries to suit your specific needs!

[Check out this CodePen](https://codepen.io/team/wtc/pen/mNdgxd) and then take their [carousel library for a spin](https://github.com/wethegit/wtc-controller-carousel).

---

## Around the Campfire
I’d like to start ropin' in conversations from other parts of town. Cause at the end of the day, there’s nothin’ nicer than a warm, friendly community.

[Colby Fayock tweeted:](https://www.twitter.com/colbyfayock)
![Colby Fayock asking: "DAE read @FrontendHorse with a Cowboy Voice?"](https://dev-to-uploads.s3.amazonaws.com/i/mec9tbnwhjuqalpq51vj.png)

Let it be known that this is now canon. If Frontend Horse becomes a podcast, it’ll be voiced by [Sam Elliott](https://imgur.com/bMcGCXy).

I’ll be on the lookout for more tweets to rope in next week. Just give a holler [@FrontendHorse](https://twitter.com/frontendhorse), and I’ll hear it.

---

## So Long, Partner
Well, that’s the end of the trail for this week. I appreciate you riding with me.

Follow [@FrontendHorse on Twitter](https://twitter.com/frontendhorse), and if you enjoyed this, I’d be over the moon if you share it with a friend or tweet about it.

Special thanks to Jesper Vos and Liam Egan for speaking with me about their work.

This is the part where we ride off into the sunset. You take care.

_Your Neigh-bor,_
_Alex_

---

If you liked this post, head to [Frontend.Horse](https://www.frontend.horse) to subscribe! You'll get the next issue before it's posted here on Dev.