<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elvis2280</title>
    <description>The latest articles on DEV Community by Elvis2280 (@elvis2280).</description>
    <link>https://dev.to/elvis2280</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F482447%2F261010e0-a8ff-4a0e-bde0-c565a38db6f1.jpeg</url>
      <title>DEV Community: Elvis2280</title>
      <link>https://dev.to/elvis2280</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elvis2280"/>
    <language>en</language>
    <item>
      <title>NextJs Leaflet + MapBox</title>
      <dc:creator>Elvis2280</dc:creator>
      <pubDate>Mon, 14 Feb 2022 05:26:31 +0000</pubDate>
      <link>https://dev.to/elvis2280/nextjs-leaflet-mapbox-50mg</link>
      <guid>https://dev.to/elvis2280/nextjs-leaflet-mapbox-50mg</guid>
      <description>&lt;p&gt;Leaflet is an open-source library that allows us to render a map on our website where we can show data, put marks wherever we want, and a lot more things, this is so useful and cool with Mapbox because we can custom our map and make it can fit with our website color pallet palette.&lt;/p&gt;

&lt;h2&gt;
  
  
  Instalation
&lt;/h2&gt;

&lt;p&gt;First of all, we need to install &lt;a href="https://react-leaflet.js.org/" rel="noopener noreferrer"&gt;React-Leaflet&lt;/a&gt;, for this we'll use this on our npm&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm i leaflet leaflet-defaulticon-compatibility leaflet-geosearch react-leaflet&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;after this is added to our package.json we can import this to our map component, I recommend you to create a separate component for the map, something like Map.jsx and add there all the necessary code and import all the dependence we need for our map&lt;/p&gt;

&lt;p&gt;So, in our Map.jsx let's import the next things&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet';
import 'leaflet/dist/leaflet.css';
import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css';
import 'leaflet-defaulticon-compatibility';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Components
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;MapContainer:&lt;/strong&gt; this wrap and display our map, so we need to pass some props &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;center: we need to pass the latitude and longitude in an array something like [8.9880228180055, -79.52932768202]&lt;/li&gt;
&lt;li&gt;zoom: we pass a number, more high number means more zoom &lt;/li&gt;
&lt;li&gt;scrollWheelZoom: true or false for allowing zoom with the mouse scroll&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;TileLayer:&lt;/strong&gt; this allows us to add our custom map and attribution if we want &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Marker:&lt;/strong&gt; this holds all the popup we wanna add to a point in the map&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;position: this is the place we wanna add the mark&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Popup:&lt;/strong&gt; We can add all the HTML labels or components around this, then display that in the popup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Map's code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet';
import 'leaflet/dist/leaflet.css';
import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css';
import 'leaflet-defaulticon-compatibility';
import { chakra, Flex } from '@chakra-ui/react';

const MapFooter = () =&amp;gt; {
  const place = [8.988022628180055, -79.52932561768202];
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;MapContainer
        center={place}
        zoom={17}
        scrollWheelZoom={false}
        style={{ width: '100%', height: '350px' }}
      &amp;gt;
        &amp;lt;TileLayer
          attribution='Map data &amp;amp;copy; &amp;lt;a href="https://www.openstreetmap.org/"&amp;gt;OpenStreetMap&amp;lt;/a&amp;gt; contributors, &amp;lt;a href="https://creativecommons.org/licenses/by-sa/2.0/"&amp;gt;CC-BY-SA&amp;lt;/a&amp;gt;, Imagery &amp;amp;copy; &amp;lt;a href="https://www.mapbox.com/"&amp;gt;Mapbox&amp;lt;/a&amp;gt;'
          url="https://api.mapbox.com/styles/v1/**YOUR_USER_NAME**/**YOUR_STYLE_TOKEN**/tiles/256/{z}/{x}/{y}@2x?access_token=**YOUR_ACCESS_TOKEN**"
        /&amp;gt;
        &amp;lt;Marker position={place}&amp;gt;
          &amp;lt;Popup className="mapBtn"&amp;gt;
            &amp;lt;Flex flexDir={'column'} alignItems="center"&amp;gt;
              &amp;lt;chakra.p fontWeight={'bold'} fontSize="lg"&amp;gt;
                Anubis
              &amp;lt;/chakra.p&amp;gt;
              &amp;lt;chakra.a
                target={'_blank'}
                href="https://goo.gl/maps/3bqJp4NzEiQU86ai6"
                bg={'primary.900'}
                textDecor={'none'}
                p="2"
                rounded={'base'}
                style={{ color: 'orange !important' }}
                _hover={{
                  bg: 'primary.400',
                }}
              &amp;gt;
                Google Maps
              &amp;lt;/chakra.a&amp;gt;
            &amp;lt;/Flex&amp;gt;
          &amp;lt;/Popup&amp;gt;
        &amp;lt;/Marker&amp;gt;
      &amp;lt;/MapContainer&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default MapFooter;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Fix NextJs problem with Leaflet
&lt;/h2&gt;

&lt;p&gt;The leaflet is made without thinking about SSR so it works with the windows object is not defined when the SSR start preparing our components for render the website, this will make you have an error like &lt;strong&gt;windows is undefined&lt;/strong&gt; for fix this we need to use something we can find in the nextjs &lt;a href="https://nextjs.org/docs/advanced-features/dynamic-import" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;&lt;br&gt;
then in the component we wanna add our map component, we have to import it with a dynamic function is made by nextjs&lt;br&gt;
is something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const MapLealfet = dynamic(() =&amp;gt; import('../MapFooter/MapFooter'), {
  ssr: false,
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with this, your map should work fine now :) &lt;/p&gt;

&lt;h2&gt;
  
  
  Custom Map with MapBox
&lt;/h2&gt;

&lt;p&gt;How maybe you realize in the URL of our TileLayer have a direction with names like &lt;strong&gt;YOUR_USER_NAME&lt;/strong&gt;, &lt;strong&gt;YOUR_STYLE_TOKEN&lt;/strong&gt; and &lt;strong&gt;YOUR_ACCESS_TOKEN&lt;/strong&gt; this is because you need to add this information using your MapBox's account, so go to &lt;a href="https://www.mapbox.com/" rel="noopener noreferrer"&gt;MapBox&lt;/a&gt; and create your account&lt;/p&gt;

&lt;p&gt;When you access your account you should see something like this&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644813736%2FScreenshot_2022_02_13_at_7_37_07_PM_ex5g1a_416b52651d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644813736%2FScreenshot_2022_02_13_at_7_37_07_PM_ex5g1a_416b52651d.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1644813616/blogs/Screenshot_2022-02-13_at_7.37.07_PM_ex5g1a.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then after that let's create a new style, click that button and you should see something now like this &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644813861%2FScreenshot_2022_02_13_at_7_37_58_PM_rthfac_1b6728e33e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644813861%2FScreenshot_2022_02_13_at_7_37_58_PM_rthfac_1b6728e33e.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1644813618/blogs/Screenshot_2022-02-13_at_7.37.58_PM_rthfac.png"&gt;&lt;/a&gt;&lt;br&gt;
here you can choose the style you prefer and after that you can even custom more that like change the street color, bus street color etc.&lt;/p&gt;

&lt;p&gt;is something like this&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644814020%2FScreenshot_2022_02_13_at_7_38_23_PM_q7p6ys_bffd370610.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644814020%2FScreenshot_2022_02_13_at_7_38_23_PM_q7p6ys_bffd370610.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1644813620/blogs/Screenshot_2022-02-13_at_7.38.23_PM_q7p6ys.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now enter to your account that will show you a dashboard with tokens, I recommend you to create a Token per map you wanna use then it will work separately and can skip some future problems&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644814242%2FScreenshot_2022_02_13_at_7_39_38_PM_b6bjtq_6bc6aa98ab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644814242%2FScreenshot_2022_02_13_at_7_39_38_PM_b6bjtq_6bc6aa98ab.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1644813616/blogs/Screenshot_2022-02-13_at_7.39.38_PM_b6bjtq.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644814276%2FScreenshot_2022_02_13_at_7_41_05_PM_uspeba_40ef8d8de4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644814276%2FScreenshot_2022_02_13_at_7_41_05_PM_uspeba_40ef8d8de4.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1644813617/blogs/Screenshot_2022-02-13_at_7.41.05_PM_uspeba.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so the final part is to come to our styles section and click on the share icon of the style we wanna use, which will show this&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644814416%2FScreenshot_2022_02_13_at_7_46_22_PM_l1fg5s_60ead98645.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644814416%2FScreenshot_2022_02_13_at_7_46_22_PM_l1fg5s_60ead98645.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1644813618/blogs/Screenshot_2022-02-13_at_7.46.22_PM_l1fg5s.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;here we have &lt;br&gt;
our username, our style token and you can use the access token we create for the map in our account section.&lt;br&gt;
so add that information in the TileLayer URL --&amp;gt;  url="&lt;a href="https://api.mapbox.com/styles/v1/**YOUR_USER_NAME**/**YOUR_STYLE_TOKEN**/tiles/256/%7Bz%7D/%7Bx%7D/%7By%7D@2x?access_token=**YOUR_ACCESS_TOKEN**" rel="noopener noreferrer"&gt;https://api.mapbox.com/styles/v1/**YOUR_USER_NAME**/**YOUR_STYLE_TOKEN**/tiles/256/{z}/{x}/{y}@2x?access_token=**YOUR_ACCESS_TOKEN**&lt;/a&gt;"&lt;/p&gt;

&lt;h2&gt;
  
  
  Final
&lt;/h2&gt;

&lt;p&gt;So here you should have a custom map cool can fit perfectly in your website design with the ability to add icons and the directions we need, and show different data we need, there is not limit for your creativity &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644815883%2FScreenshot_2022_02_14_at_12_15_32_AM_ymt4r8_2ae80a3050.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1644815883%2FScreenshot_2022_02_14_at_12_15_32_AM_ymt4r8_2ae80a3050.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1644815825/blogs/Screenshot_2022-02-14_at_12.15.32_AM_ymt4r8.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank u for read this article and give me some of your time, feel free to visit my &lt;a href="https://elvisdev-portfolio.netlify.app/" rel="noopener noreferrer"&gt;website&lt;/a&gt; if you want :)&lt;br&gt;
Happy Code!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
    </item>
    <item>
      <title>Scroll reveal with Framer Motion</title>
      <dc:creator>Elvis2280</dc:creator>
      <pubDate>Sun, 22 Aug 2021 02:01:04 +0000</pubDate>
      <link>https://dev.to/elvis2280/scroll-reveal-with-framer-motion-224</link>
      <guid>https://dev.to/elvis2280/scroll-reveal-with-framer-motion-224</guid>
      <description>&lt;p&gt;Framer Motion is a library for creating awesome animations on React in an easy and fast way, it let us create simple or complex animation with components and set values like props, we're familiar with React. Something I really like about Framer motion is how we can make animations without expending time creating a CSS file and setting up everything this allows us to create something really awesome in a short period of time.&lt;/p&gt;

&lt;p&gt;In this blog I'll show you how u can implement a Scroll reveal animation with framer motion, you'll be surprised how much easy it will be.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'll use React-Interception-Observer to control the screen events you can check the &lt;a href="https://github.com/thebuilder/react-intersection-observer" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; if you wanna know more.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Of course, you can create a React custom Hook to control the intersection in the screen or also use vanilla js with &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API" rel="noopener noreferrer"&gt;Intersection Observer API&lt;/a&gt; but in this case, I wanna show a small React library that let us control intersection in react easy and fast.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing necessary libraries
&lt;/h3&gt;

&lt;p&gt;First lets to install the &lt;strong&gt;libraries&lt;/strong&gt; for our project&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;npm install react-intersection-observer --save&lt;/li&gt;
&lt;li&gt;npm install framer-motion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'll create a Box component just to animate it and show it while we scroll down, but you can use any component or element for example a card, title, etc...  you have in your application&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1629568021%2FScreenshot_2021_08_20_at_7_12_30_PM_rvgeo1_b6183b504b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1629568021%2FScreenshot_2021_08_20_at_7_12_30_PM_rvgeo1_b6183b504b.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1629567992/blogs/Screenshot_2021-08-20_at_7.12.30_PM_rvgeo1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  React-Interception-Observer library
&lt;/h4&gt;

&lt;p&gt;Now let's import React-Interception-Observer library to our component taking &lt;strong&gt;useInView&lt;/strong&gt; hook&lt;/p&gt;

&lt;p&gt;and now we have to use the useInView hook and distructure it like this&lt;br&gt;
const {inView, entry, ref} = useInView();&lt;br&gt;
InView tells us with a false or true when the element is on the screen view, entry is the information between the root and the component is like the different status it has while we scroll down&lt;br&gt;
and ref is for the DOM element we wanna observe&lt;/p&gt;

&lt;p&gt;Right now it should look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {useInView} from "react-intersection-observer";
const Box = ({text}) =&amp;gt; {

  const {inView, entry, ref} = useInView();
  return (
    &amp;lt;div ref={ref}&amp;gt;
    {text} 
    &amp;lt;/div&amp;gt;
  )
}
export default Box;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Animation with Framer motion
&lt;/h3&gt;

&lt;p&gt;Then now let's start the animation part, We'll do the next steps&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Import framer motion to our component&lt;/li&gt;
&lt;li&gt;use motion component&lt;/li&gt;
&lt;li&gt;create an initial animation&lt;/li&gt;
&lt;li&gt;use framer motion &lt;strong&gt;useAnimation&lt;/strong&gt; hook&lt;/li&gt;
&lt;li&gt;start the animation when &lt;strong&gt;inView&lt;/strong&gt; is true
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { motion, useAnimation } from "framer-motion";

&amp;lt;div ref={ref}&amp;gt;
    &amp;lt;motion.div

      initial={{
        x: "100vw"
      }}
      animate={animationControl}
      className="box"
    &amp;gt;
      {text}
    &amp;lt;/motion.div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, we import &lt;strong&gt;motion&lt;/strong&gt; and &lt;strong&gt;useAnimation&lt;/strong&gt; from our library Framer-motion.&lt;br&gt;
In this case, we have to use a &lt;/p&gt; like container to let our website know where's the element we're animating if we don't use a container in our first animation when we use a transformX 100vw it will disappear from our screen view and our website will not know when is the moment to fire the animation because don't find any element with ref in our viewport, then in the  container we'll put our ref for following that element.
&lt;h4&gt;
  
  
  Motion component
&lt;/h4&gt;

&lt;p&gt;motion component lets us create our animation through props, we can create any motion component from HTML labels.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;for example motion.a, motion.div, motion.main, motion.p etc...&lt;br&gt;
We have different props for these components, I invite you to check &lt;a href="https://www.framer.com/docs/animation/#component-animation-controls" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; for know more about it.&lt;br&gt;
in this example, we'll use &lt;strong&gt;animate&lt;/strong&gt; and &lt;strong&gt;initial&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Motion initial prop
&lt;/h4&gt;

&lt;p&gt;initial is from where we want our component to start to do the animation, in this case, we wanna our component to start from 100vw to make it disappear in the right X corner.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: check your container that holds all the app elements have a  overflow-x: hidden to avoid your website is broken because the elements are over the screen view waiting to be a fire&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Motion control animation
&lt;/h4&gt;

&lt;p&gt;well... everything looks fine but how we'll fire our elements because now it disappears and that's not our objective right ?.&lt;br&gt;
Here is where &lt;strong&gt;useAnimation&lt;/strong&gt; hook comes to help us, it allows us to start or stop our animation and it's exactly what we're looking for.&lt;/p&gt;

&lt;p&gt;first, we need to create a variable for saving the object that comes from the hook&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; const animationControl = useAnimation();
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;you can use any name u want, this will let us control our animation&lt;br&gt;
and now we can do something simple like this&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (inView) {
    animationControl.start({
      x: 0,
      transition: {
        delay: 0.7,
      }
    });
  }
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;this means if &lt;strong&gt;inView&lt;/strong&gt; is true (element is on our viewport) then we'll call our control method to start the animation we want, in this case, make the element comeback at x: 0, it means to come back to the initial position where this should be&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I add a delay to 700ms for don't fire it immediately then the user can enjoy more of the animation watching the element completely.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Motion animate prop
&lt;/h4&gt;

&lt;p&gt;finally, we have to show or fire the animation, we created a control that will only allow firing the animation when it's in the viewport but to show or run that animation we need to use the animate prop it gets an object with the property we want, in this case, we'll use &lt;strong&gt;animationControl&lt;/strong&gt; who have the object we set in the previous step.&lt;/p&gt;

&lt;p&gt;the final code should look like&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1629534340%2FScreenshot_2021_08_20_at_10_39_18_PM_j3paty_98927eebbb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1629534340%2FScreenshot_2021_08_20_at_10_39_18_PM_j3paty_98927eebbb.png" alt="https://res.cloudinary.com/elvisdev2280/image/upload/v1629534308/blogs/Screenshot_2021-08-20_at_10.39.18_PM_j3paty.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Result
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1629528196%2Fezgif_com_gif_maker_pur1ja_a15b2812d8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Felvisdev2280%2Fimage%2Fupload%2Fv1629528196%2Fezgif_com_gif_maker_pur1ja_a15b2812d8.gif" alt="ezgif.com-gif-maker_pur1ja.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this was useful for you :), feel free to check my personal &lt;a href="https://elvisdev-portfolio.netlify.app/" rel="noopener noreferrer"&gt;website&lt;/a&gt; have a great day Happy Code 🧑🏻‍💻&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Help, how to organize or to create a study plan</title>
      <dc:creator>Elvis2280</dc:creator>
      <pubDate>Tue, 13 Oct 2020 22:21:11 +0000</pubDate>
      <link>https://dev.to/elvis2280/help-how-to-organize-or-to-create-a-study-plan-303o</link>
      <guid>https://dev.to/elvis2280/help-how-to-organize-or-to-create-a-study-plan-303o</guid>
      <description>&lt;p&gt;Hello, I'm curious about how other developments organize the time for study, I'm in the university but I have a problem, when I study CSS or javascript I expending all my day on that, I just can't stop, I feel I need have control or balance about my study. I hope someone can help me with ideas :)&lt;/p&gt;

</description>
      <category>help</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What's the front-end rol</title>
      <dc:creator>Elvis2280</dc:creator>
      <pubDate>Tue, 13 Oct 2020 01:07:19 +0000</pubDate>
      <link>https://dev.to/elvis2280/what-s-the-front-end-rol-2ncn</link>
      <guid>https://dev.to/elvis2280/what-s-the-front-end-rol-2ncn</guid>
      <description>&lt;p&gt;Hello, I have a small project I don't have so much experience just 7 months how front end, but my question is, I knot HTML is for structure and CSS design, but I also know JavaScript is so important just I don't understand in what situation front-end use JS, I have to do a filter bottom for cost and games category but I wonder if it's a front end role or back end, Honestly I don't understand so much difference roles (what I should do and learn and what no). thank you so much for helping me :)&lt;/p&gt;

</description>
      <category>help</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
