<?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 Patryk Mastrzykowski on Medium]]></title>
        <description><![CDATA[Stories by Patryk Mastrzykowski on Medium]]></description>
        <link>https://medium.com/@PMastrzykowski?source=rss-f609b2d7239f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C3hYf8EDAHM---naPj3eFw.png</url>
            <title>Stories by Patryk Mastrzykowski on Medium</title>
            <link>https://medium.com/@PMastrzykowski?source=rss-f609b2d7239f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:53:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@PMastrzykowski/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[Modal Wrapper with React + Greensock]]></title>
            <link>https://medium.com/@PMastrzykowski/modal-wrapper-with-react-greensock-d50858d77fb4?source=rss-f609b2d7239f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d50858d77fb4</guid>
            <category><![CDATA[greensock]]></category>
            <category><![CDATA[modal]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Patryk Mastrzykowski]]></dc:creator>
            <pubDate>Wed, 16 May 2018 18:11:54 GMT</pubDate>
            <atom:updated>2018-05-16T18:11:54.635Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6pX0rw7tjvgRxtHcl0APQ.png" /><figcaption>Application example</figcaption></figure><p>For those who believe that impossible is nothing, especially in frontend, here I come with an animated React modal wrapper component example. In this short article I’ll explain how to do it with Greensock. What we are going to achieve, is a modal that resizes on content’s change. It can be useful e.g switching from ‘Log in’ to ‘Register’ view.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FvgAAc3BkhWieeb0aFQ%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FvgAAc3BkhWieeb0aFQ%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FvgAAc3BkhWieeb0aFQ%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/86b62e8c68e78692646533a9c39881d8/href">https://medium.com/media/86b62e8c68e78692646533a9c39881d8/href</a></iframe><p>As per my design, modal is a wrapper containing a given content. The thing is, a content can be different size each time rendered, so the most important functionality concerns modal resizing. Open modal animation is initialized directly from the Modal’s componentDidMount lifecycle method, and as we want the component to be reusable, we will initialize animated unmounting from the inside too. There is unfortunately no native component lifecycle method suitable for unmounting animations (some React dedicated animation libraries come to help, but as Greensock gives infinite possibilities, I’ll stay with it).</p><p>React best practice states to manage unmounting children from their parent element, so we’ll pass a callback function helping with unmounting and run it at the end of hiding modal animation. Resizing modal is simply an animation launched every time the component updates.</p><p>To be able to manipulate modal state from it’s content component, changeContent and closeModal functions are passed to all of the children using React.cloneElement. A changeContent method receives a payload of a callback function passed from the content component to unmount the current content component and mount the new one.</p><p>Closing can be initialized both from the inside and from the outside of the component. Displaying closing icon is customized in Modal’s parent and passed as a prop. The closing SVG icon is used as a separate component, allowing JavaScript interference. To keep the modal always in the center of the window, resize listener is added once the component is mounted.</p><p>User can change modal’s content clicking on it. Full repository lives <a href="https://github.com/PMastrzykowski/Modal-Wrapper-with-React-Greensock">here</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e33921d5b1509539ae838f71263ec94d/href">https://medium.com/media/e33921d5b1509539ae838f71263ec94d/href</a></iframe><p>And here the Greensock part comes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c81f56a66a202d15212bbf38a8379e53/href">https://medium.com/media/c81f56a66a202d15212bbf38a8379e53/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d50858d77fb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>