<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vincent van der Meulen on Medium]]></title>
        <description><![CDATA[Stories by Vincent van der Meulen on Medium]]></description>
        <link>https://medium.com/@vincentmvdm?source=rss-6ac5010c69d7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*t8n0DBLiM-UTOQ9K8BjZCg.jpeg</url>
            <title>Stories by Vincent van der Meulen on Medium</title>
            <link>https://medium.com/@vincentmvdm?source=rss-6ac5010c69d7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 19:55:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vincentmvdm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Recreating Spotify’s Scroll Animation in Framer X]]></title>
            <link>https://medium.com/@vincentmvdm/recreating-spotifys-scroll-animation-in-framer-x-5e116de5b716?source=rss-6ac5010c69d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e116de5b716</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[framer-x]]></category>
            <category><![CDATA[prototyping]]></category>
            <category><![CDATA[framer]]></category>
            <dc:creator><![CDATA[Vincent van der Meulen]]></dc:creator>
            <pubDate>Tue, 16 Jul 2019 11:02:02 GMT</pubDate>
            <atom:updated>2019-07-16T19:46:12.525Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZceu5CjJc5PJF89KDxDiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*UaiJphJarCRx7bKal5kDMw.gif" /></figure><p>Spotify’s scroll animation is a textbook example of how to use motion to draw users into a page. <a href="https://twitter.com/vincentmvdm/status/1112115615546761217">A few months back</a>, I recreated the effect in Framer X. Here’s how to do it.</p><p><a href="https://drive.google.com/open?id=1yaSAZfEdTsfRiYuKC2t4opV6TkGrGI5D"><em>Download the commented source file</em></a></p><h3>1. Designing the interface</h3><p>We first need to create the layout using design components. The page is image-heavy. We can fill in all the cover art using the <a href="https://store.framer.com/package/unsplash/unsplash">Unsplash Images</a> package in the Store. The package <a href="https://store.framer.com/package/benjamin/icon-generator">Icon Generator</a> gives us easy access to <a href="https://feathericons.com/">Feather Icons</a>. The most important component is the Scroll component. Our goal is to animate the design components as the user scrolls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3qRJcTdAqorz-tg8BqfZA.png" /></figure><h3>2. Keeping track of the scroll distance</h3><p>We need to keep track of the scroll distance or how much the user has scrolled. We can make a variable to hold the scroll distance in pixels (integer) and make the Scroll component update it. Let’s call this variable scrollDistance.</p><p>The scroll distance will change constantly. The Scroll component updates it even when the user scrolls only a single pixel. We can let Framer know scrollDistance is a rapidly changing measure of motion by using a MotionValue instead of a plain number:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0aeb78fd04fb474ff6b440701d499f4/href">https://medium.com/media/b0aeb78fd04fb474ff6b440701d499f4/href</a></iframe><p>Framer components like our Scroll component know how to update MotionValues. We just need to provide our Scroll component with our MotionValue! Create an Override that returns the MotionValue as a prop called contentOffsetY and apply it to the Scroll component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f62ce36a163f4a28f2bd459baf34c31/href">https://medium.com/media/7f62ce36a163f4a28f2bd459baf34c31/href</a></iframe><p>The Scroll component now receives our MotionValue as a prop. Scroll components update any MotionValue passed to them as contentOffsetY when the user scrolls.</p><h3>3. Animating elements on scroll</h3><p>We can use the scroll distance to animate our design components. Many elements change as the Spotify user scrolls. Let’s focus on the artist name (“Framerista”) for now.</p><p>The artist name fades out on scroll. We know that we need to override its opacity. Make the following Override and apply it to the design component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebaffc8363080d734c6ad29191a3cf6b/href">https://medium.com/media/ebaffc8363080d734c6ad29191a3cf6b/href</a></iframe><p>The artist name now uses our Override’s opacity property. But the opacity is always 1. We need to modify our Override’s opacity every time the scroll distance changes. Spotify fades out the artist name when the user scrolls down. It’s faded out completely by the time the user has scrolled 224px. We need to change the artist name’s opacity from 1 to 0 as our scrollDistance MotionValue changes from 0 to -224px. The scroll distance is negative because the content moves up when the user scrolls down.</p><p>We have a MotionValue (scroll distance) in one range and need to transform it into a MotionValue in another range (opacity). We can do this using the useTransform function. useTransform takes four arguments. The first argument is the input or MotionValue we want to transform. The second argument is the input value’s range. The third argument is the output value’s range. The fourth argument is an optional options object. Framer stops transforming the input when it’s outside of the provided range. The opacity remains 0 if the user keeps scrolling. Animating the artist name’s opacity from 1 to 0 as the user scrolls down 224px looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a55607e889484ecbfe21e92845b4deb0/href">https://medium.com/media/a55607e889484ecbfe21e92845b4deb0/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*R3aWfOadWvSbMzdRcM9H2A.gif" /></figure><p>We can add as many scroll animations as we’d like now that we have the basics down. For example, we can decrease the text size:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82d421d4faf2ca0c21b8737c65bc1156/href">https://medium.com/media/82d421d4faf2ca0c21b8737c65bc1156/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*hA-U3Tkw1L8Oc2gL0WUpqA.gif" /></figure><h3>4. Polishing our animations</h3><p>Our design changes as the user scrolls but our animations feel dull and unnatural. They are linear: the opacity always changes at the same rate in the previous example. That isn’t very exciting nor how objects behave in the real world. How do we get closer to the animation we’re trying to imitate?</p><p>We can make our animations feel more lively by specifying easing. The NPM package @popmotion/easing has easing functions for common animation curves like <em>cubic-bezier</em>. We can install this package by opening our project folder in Terminal and running the command npm install @popmotion/easing. You can locate your project folder by going to File -&gt; Show Project Folder.</p><p>useTransform lets us specify the animation’s easing as part of its fourth argument or options object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb1fc21611d09b7429ba881635beba7b/href">https://medium.com/media/fb1fc21611d09b7429ba881635beba7b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*Lmu4CNg6GZ2o_AxtTMlGXQ.gif" /></figure><p>Mimicking Spotify leads to five Overrides like this that change a design component’s appearance when the user scrolls.</p><h3>5. Making it stick</h3><p>One of the harder scroll animations is the pause button that becomes sticky past a certain distance. We could use the same technique as we have used so far. However, the arguments we need to pass into useTransform become less straightforward.</p><p>It’s easier to grab Giles Perry’s <a href="https://store.framer.com/package/perrysmotors/sticky-headers">Sticky Headers</a> package from the Store. Swap out the Scroll component for the StickyScroll component. Connect the StickyElement component to the button. Lastly, make sure the StickyElement component is inside of the StickyScroll component. All done!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*K_brb1qsuAFpj1Kt-g1Fig.gif" /></figure><h3>6. Please don’t stop the music</h3><p>Our scroll animation now looks identical to Spotify’s. But what if we wanted to use it in user testing? Our prototype needs to look real and appear to play a song. Luckily, we can animate the progress bar’s width.</p><p>First, we need to keep track of the elapsed time. In Framer X, we use Data objects when we want to store values (that aren’t MotionValues) for use in Overrides. Data objects look and behave like regular JavaScript objects. Framer updates an Override when it uses a value stored in a Data object and this value changes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c3d2eb3dc047bbaa44efecf2dd136ba/href">https://medium.com/media/3c3d2eb3dc047bbaa44efecf2dd136ba/href</a></iframe><p>We need to increase elapsedMs as time passes. Ideally, we update it frequently enough that our progress bar animates smoothly. We could use the built-in JavaScript function setInterval to regularly update elapsedMs. However, setInterval becomes unreliable when the browser is busy. We run the risk that it won’t update elapsedMs at 60 fps. The result is a choppy animation.</p><p>But all hope isn’t lost! We can use the browser’s requestAnimationFrame function. The following code runs the timer function 60 times per second:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5283885d77ba42c9d3bc6438fdf70b8/href">https://medium.com/media/c5283885d77ba42c9d3bc6438fdf70b8/href</a></iframe><p>The browser automatically passes the current time in milliseconds as an argument to our function. We can use this to calculate how much time has passed and update elapsedMs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a24ed2863ac1599a35d25aabbc8df543/href">https://medium.com/media/a24ed2863ac1599a35d25aabbc8df543/href</a></iframe><p>Finally, we need to animate the progress bar’s width as time elapses. We have to use Framer’s transform function instead of useTransform because elapsedMs is a regular number and not a MotionValue. The idea is the same:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/377aa224c2bd8bcac791ccbbf032980c/href">https://medium.com/media/377aa224c2bd8bcac791ccbbf032980c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*YT2l_0x9A7EBk2Qdr_SE6w.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*UaiJphJarCRx7bKal5kDMw.gif" /></figure><p>That’s it! The cool thing about knowing how to work with MotionValues and useTransform is that we can create other scroll effects, such as parallax, as well as most animations in today’s popular apps.</p><p>Until next time,</p><p>Vincent</p><p><em>Thanks to Parker Henderson for reviewing the source file and Giles Perry for his </em><a href="https://www.framer.com/blog/posts/mastering-scrolling/"><em>wonderful article on scrolling in Framer X</em></a><em>.</em></p><p><em>Questions? </em><a href="https://twitter.com/vincentmvdm"><em>Send me a tweet</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e116de5b716" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>