<?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: Sabiya Tabassum</title>
    <description>The latest articles on DEV Community by Sabiya Tabassum (@sabiyatabassum).</description>
    <link>https://dev.to/sabiyatabassum</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%2F560331%2F76c00398-76ee-456e-a0fe-454719b08658.png</url>
      <title>DEV Community: Sabiya Tabassum</title>
      <link>https://dev.to/sabiyatabassum</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sabiyatabassum"/>
    <language>en</language>
    <item>
      <title>Day-22 Drawing App</title>
      <dc:creator>Sabiya Tabassum</dc:creator>
      <pubDate>Fri, 18 Jun 2021 13:09:36 +0000</pubDate>
      <link>https://dev.to/sabiyatabassum/day-22-drawing-app-2igi</link>
      <guid>https://dev.to/sabiyatabassum/day-22-drawing-app-2igi</guid>
      <description>&lt;p&gt;Hi Folks,&lt;/p&gt;

&lt;p&gt;Before diving into the project, a little bit of &lt;strong&gt;introduction&lt;/strong&gt; about me:&lt;/p&gt;

&lt;p&gt;I am &lt;strong&gt;Sabiya Tabassum&lt;/strong&gt;. I completed my B.Tech under CSE major. I'm currently learning React and recently, I have started 50 Projects 50 Days challenge. If you have any queries/ ideas to collaborate with me, you can connect with me at my social media handles.&lt;/p&gt;

&lt;p&gt;Coming to our &lt;strong&gt;Drawing App Project&lt;/strong&gt;, Let's dive into it!!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lGLoqPKa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q68teq3c52yntk3t2vm6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lGLoqPKa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q68teq3c52yntk3t2vm6.gif" alt="Wohoo" width="576" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Glimpse of the &lt;strong&gt;output&lt;/strong&gt; of our project:&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/Day-22-Drawing-App-uyfre"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;From the above image, we can get an idea that there is a canvas to draw. And a toolbox to increase or to decrease the thickness, a color input to change the color of the stroke and a clear button to clear the canvas.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tech stack&lt;/strong&gt; we are using: HTML,CSS, JS&lt;/p&gt;

&lt;p&gt;📌&lt;strong&gt;HTML code:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;canvas class="canvas" id="canvas" width="600" 
   height="500"&amp;gt;&amp;lt;/canvas&amp;gt;
  &amp;lt;div class="toolbox" id="toolbox"&amp;gt;
     &amp;lt;button class="decrement"&amp;gt;-&amp;lt;/button&amp;gt;
     &amp;lt;span id="size" class="size"&amp;gt;10&amp;lt;/span&amp;gt;
     &amp;lt;button class="increment"&amp;gt;+&amp;lt;/button&amp;gt;
     &amp;lt;input type="color" class="color" /&amp;gt;
     &amp;lt;button class="clear" id="clear"&amp;gt;X&amp;lt;/button&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Detailed Explanation of HTML code:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From the output, we can get a clear idea that we need a canvas.
Add width and height attributes to the canvas.&lt;/li&gt;
&lt;li&gt;For the toolbox, we create a  called toolbox in which we 
have buttons for &lt;strong&gt;decrement&lt;/strong&gt; and &lt;strong&gt;increment&lt;/strong&gt;. Also take a 
&lt;strong&gt;span&lt;/strong&gt; tag for &lt;strong&gt;size&lt;/strong&gt; class which indicates the thickness of 
the line/stroke.
&lt;/li&gt;
&lt;li&gt;Add a button containing a &lt;strong&gt;clear&lt;/strong&gt; class to clear the canvas.&lt;/li&gt;


&lt;p&gt;📌&lt;strong&gt;CSS code:&lt;/strong&gt;&lt;/p&gt;
&lt;/ul&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   @import url("https://fonts.googleapis.com/css2? 
   family=Roboto:wght@400;700&amp;amp;display=swap");
 * {
      box-sizing: border-box;
   }
 body {
      background-color: #f5f5f5;
      font-family: "Roboto", sans-serif;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100vh;
      margin: 0;
   }
 canvas {
      border: 4px solid steelblue;
   }
 .toolbox {
     background-color: rgb(62, 138, 201);
     width: 606px;
     height: 60px;
     display: flex;
     border: 2px solid rgb(25, 141, 236);
     padding: 10px 20px;
     }
  .toolbox &amp;gt; * {
     display: inline-flex;
     align-items: center;
     justify-content: center;
     margin: 4px;
     padding: 10px;
     font-size: 1.8rem;
     background-color: #fff;
     border: 0;
     cursor: pointer;
     width: 40px;
     height: 39px;
     margin-top: -2px;
  }
 .toolbox &amp;gt; *:last-child {
     margin-left: auto;
     background-color: red;
     color: white;
   }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Detailed explanation of CSS code:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For &lt;strong&gt;Centering of elements&lt;/strong&gt;: Add properties like,

&lt;ul&gt;
&lt;li&gt;display:flex - To lay a collection of items out in one 
              direction or another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;align-items:center&lt;/strong&gt; - Centering the items.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;justify-content:center&lt;/strong&gt; - Aligns the flexible 
              container's items to center.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;height:100vh&lt;/strong&gt; - The page's overall height&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;overflow: hidden&lt;/strong&gt; - This property makes the page 
              unscrollable.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;styling the canvas&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Add a &lt;strong&gt;border&lt;/strong&gt; property.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;styling the toolbox&lt;/strong&gt;: 

&lt;ul&gt;
&lt;li&gt;Specify the &lt;strong&gt;width&lt;/strong&gt; and &lt;strong&gt;height&lt;/strong&gt; for the toolbox.&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;background-color&lt;/strong&gt; and &lt;strong&gt;padding&lt;/strong&gt;, &lt;strong&gt;margin&lt;/strong&gt; 
properties as ur wish.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;.toolbox &amp;gt; * {}&lt;/strong&gt; means:

&lt;ul&gt;
&lt;li&gt;The children in the parent &lt;strong&gt;toolbox&lt;/strong&gt; class gets effected to 
the styles that we write into these parentheses column. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;.toolbox &amp;gt; *:last-child{}&lt;/strong&gt; means:

&lt;ul&gt;
&lt;li&gt;The last child only gets effected to the styles that we write 
into these parentheses.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Atlast, you can add some media queries for responsiveness 😊 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌&lt;strong&gt;JS code:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const canvas = document.querySelector(".canvas");
  const incrementBtn = document.querySelector(".increment");
  const decrementBtn = document.querySelector(".decrement");
  const colorEl = document.querySelector(".color");
  const clearEl = document.querySelector(".clear");
  const sizeEl = document.querySelector(".size");

  let size = 10;
  let isPressed = false;
  colorEl.value = "black";
  let color = colorEl.value;
  let x;
  let y;

  const ctx = canvas.getContext("2d");

  canvas.addEventListener("mousedown", (e) =&amp;gt; {
          isPressed = true;
          x = e.offsetX;
          y = e.offsetY;
  });

  canvas.addEventListener("mouseup", (e) =&amp;gt; {
         isPressed = false;
         x = undefined;
         y = undefined;
  });

 canvas.addEventListener("mousemove", (e) =&amp;gt; {
        if (isPressed) {
           const x2 = e.offsetX;
           const y2 = e.offsetY;

           drawCircle(x2, y2);
           drawLine(x, y, x2, y2);
           x = x2;
           y = y2;
       }
 });

 function drawCircle(x, y) {
          ctx.beginPath();
          ctx.arc(x, y, size, 0, Math.PI * 2);
          ctx.fillStyle = color;
          ctx.fill();
  }

 function drawLine(x1, y1, x2, y2) {
          ctx.beginPath();
          ctx.moveTo(x1, y1);
          ctx.lineTo(x2, y2);
          ctx.strokeStyle = color;
          ctx.lineWidth = size * 2;
          ctx.stroke();
  }

 function updateSizeOnScreen() {
         sizeEl.innerText = size;
  }

 incrementBtn.addEventListener("click", () =&amp;gt; {
         size += 5;
         if (size &amp;gt; 50) {
             size = 50;
          }
          updateSizeOnScreen();
 });

  decrementBtn.addEventListener("click", () =&amp;gt; {
         size -= 5;
         if (size &amp;lt; 5) {
             size = 5;
          }
         updateSizeOnScreen();
   });

  colorEl.addEventListener("change", (e) =&amp;gt; {
         color = e.target.value;
  });

  clearEl.addEventListener("click", () =&amp;gt; {
         ctx.clearRect(0, 0, canvas.width, canvas.height);
  });
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Detailed explanation of JS code:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firstly, create the variables on which we are making DOM 
 changes.&lt;/li&gt;
&lt;li&gt;On &lt;strong&gt;Canvas&lt;/strong&gt;, we have functions &lt;strong&gt;mousemove&lt;/strong&gt;, 
 &lt;strong&gt;mousedown&lt;/strong&gt; and &lt;strong&gt;mouseup&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;We have functions like, &lt;strong&gt;drawCircle&lt;/strong&gt;, &lt;strong&gt;drawLine&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;These functions are helpful in giving you an idea on drawing 
 elements.&lt;/li&gt;
&lt;li&gt;We have to register some events using &lt;strong&gt;addEventListener&lt;/strong&gt; on 
 &lt;strong&gt;Increment&lt;/strong&gt;, &lt;strong&gt;decrement&lt;/strong&gt;, &lt;strong&gt;size&lt;/strong&gt;, &lt;strong&gt;color&lt;/strong&gt; and &lt;strong&gt;clear&lt;/strong&gt; buttons so that when they perform some events like &lt;strong&gt;click&lt;/strong&gt;/&lt;strong&gt;change&lt;/strong&gt; a certain action to be performed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Finally, the &lt;strong&gt;Live demo&lt;/strong&gt; of &lt;strong&gt;output&lt;/strong&gt; will be:
&lt;/h2&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/Day-22-Drawing-App-uyfre"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;h4&gt;
  
  
  Github Link: &lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/nerdfswd"&gt;
        nerdfswd
      &lt;/a&gt; / &lt;a href="https://github.com/nerdfswd/Day-22-Drawing-App"&gt;
        Day-22-Drawing-App
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Day-22 Drawing App. Created with CodeSandbox
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Day-22-Drawing-App&lt;/h1&gt;
&lt;p&gt;Created with CodeSandbox&lt;/p&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/nerdfswd/Day-22-Drawing-App"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;/h4&gt;


&lt;h4&gt;
  
  
  Connect me at &lt;a href="https://twitter.com/nerd_fswd"&gt;https://twitter.com/nerd_fswd&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Hope you liked the project!!&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Today's Pinch of Motivation:
&lt;/h4&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    And I won't let you get me down
    I'll keep gettin' up when I hit the ground
    Oh, never give up, no, never give up no, no, oh
    I won't let you get me down
    I'll keep gettin' up when I hit the ground
    Oh, NEVER GIVE UP, no, never give up no, no, oh
&lt;/code&gt;&lt;/pre&gt;



</description>
      <category>javascript</category>
      <category>50projects50days</category>
      <category>day22</category>
    </item>
    <item>
      <title>Day-21 Drag N Drop</title>
      <dc:creator>Sabiya Tabassum</dc:creator>
      <pubDate>Thu, 17 Jun 2021 06:17:22 +0000</pubDate>
      <link>https://dev.to/sabiyatabassum/day-21-drag-n-drop-2afp</link>
      <guid>https://dev.to/sabiyatabassum/day-21-drag-n-drop-2afp</guid>
      <description>&lt;p&gt;Hi Folks,&lt;/p&gt;

&lt;p&gt;Before diving into the project, a little bit of &lt;strong&gt;introduction&lt;/strong&gt; about me:&lt;/p&gt;

&lt;p&gt;I am &lt;strong&gt;Sabiya Tabassum&lt;/strong&gt;. I completed my B.Tech under CSE major. I'm currently learning React and recently, I have started 50 Projects 50 Days challenge. If you have any queries/ ideas to collaborate with me, you can connect with me at my social media handles.&lt;/p&gt;

&lt;p&gt;Coming to our &lt;strong&gt;Drag N Drop Project&lt;/strong&gt;, Let's Go!!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wtK83k0U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b5wvavf7rdr8m3lwv1i6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wtK83k0U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b5wvavf7rdr8m3lwv1i6.gif" alt="Let's Go" width="461" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Glimpse of the &lt;strong&gt;output&lt;/strong&gt; of our project:&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/Day-21-Drag-N-Drop-d6qi5"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;From the above image, we can get an idea that there are some boxes. Out of these boxes, one box have an image. We can drag the image and drop in any of the boxes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tech stack&lt;/strong&gt; we are using: HTML,CSS, JS&lt;/p&gt;

&lt;p&gt;📌&lt;strong&gt;HTML code:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;div class="empty"&amp;gt;
      &amp;lt;div class="fill" draggable="true"&amp;gt;&amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
   &amp;lt;div class="empty"&amp;gt;&amp;lt;/div&amp;gt;
   &amp;lt;div class="empty"&amp;gt;&amp;lt;/div&amp;gt;
   &amp;lt;div class="empty"&amp;gt;&amp;lt;/div&amp;gt;
   &amp;lt;div class="empty"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Detailed Explanation of HTML code:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;According to the output, we need atleast 4-5 boxes. So we create 4-5  tags with an empty class inside it.
&lt;/li&gt;
&lt;li&gt;For a image in the box, we create another  inside the empty  tag. And add an attribute &lt;strong&gt;draggable="true"&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;draggable="true"&lt;/strong&gt;: The &lt;strong&gt;draggable&lt;/strong&gt; attribute specifies 
whether an element is draggable or not.&lt;/li&gt;


&lt;p&gt;📌&lt;strong&gt;CSS code:&lt;/strong&gt;&lt;/p&gt;
&lt;/ul&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   @import url("https://fonts.googleapis.com/css2? 
   family=Roboto:wght@400;700&amp;amp;display=swap");
   * {
      box-sizing: border-box;
   }
   body {
      font-family: "Roboto", sans-serif;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      margin: 0;
      height: 100vh;
   }
 .empty {
      height: 150px;
      width: 150px;
      margin: 10px;
      border: solid 3px black;
      background: white;
   }
.fill {
     background-image:
          url("https://source.unsplash.com/random/150x150");
     width: 145px;
     height: 145px;
   }
.hold {
     border: 3px solid red;
   }
.hovered {
     background-color: black;
     border-color: rgb(32, 230, 32);
     border-style: dashed;
   }
 @media (max-width: 480px) {
     body {
          flex-direction: column;
     }
 }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Detailed explanation of CSS code:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For &lt;strong&gt;Centering of elements&lt;/strong&gt;: Add properties like,

&lt;ul&gt;
&lt;li&gt;display:flex - To lay a collection of items out in one 
              direction or another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;align-items:center&lt;/strong&gt; - Centering the items.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;justify-content:center&lt;/strong&gt; - Aligns the flexible 
              container's items to center.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;height:100vh&lt;/strong&gt; - The page's overall height&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;overflow: hidden&lt;/strong&gt; - This property makes the page 
              unscrollable.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;styling the empty class&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Specify &lt;strong&gt;height&lt;/strong&gt; and &lt;strong&gt;width&lt;/strong&gt; of the box.&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;background-color&lt;/strong&gt; and &lt;strong&gt;border&lt;/strong&gt; properties.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;styling the fill class&lt;/strong&gt;: 

&lt;ul&gt;
&lt;li&gt;Add &lt;strong&gt;background-image&lt;/strong&gt; and &lt;strong&gt;height&lt;/strong&gt;, &lt;strong&gt;width&lt;/strong&gt; 
properties for the image.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Add styling to hold class and hovered class which will be created further in JS.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;hold class styling&lt;/strong&gt; - To create an effect around the image, when the image is dragged from the box. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;hovered class styling&lt;/strong&gt; - To create an effect when the image is hovering on other boxes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Atlast, Add some responsive media queries 😊 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌&lt;strong&gt;JS code:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const fill = document.querySelector(".fill");
  const empties = document.querySelectorAll(".empty");

  fill.addEventListener("dragstart", dragStart);
  fill.addEventListener("dragend", dragEnd);

  empties.forEach((empty) =&amp;gt; {
      empty.addEventListener("dragover", dragOver);
      empty.addEventListener("dragenter", dragEnter);
      empty.addEventListener("dragleave", dragLeave);
      empty.addEventListener("drop", dragDrop);
  });

  function dragStart() {
      this.className += " hold"; //append the hold class here
      setTimeout(() =&amp;gt; (this.className = "invisible"), 0);
  }

  function dragEnd() {
      this.className = "fill";
  }

  function dragOver(e) {
      e.preventDefault();
  }

  function dragEnter(e) {
      e.preventDefault();
      this.className += " hovered"; //append hovered class 
                         here while entering into the box.
  }

  function dragLeave() {
      this.className = "empty";
  }

  function dragDrop() {
      this.className = "empty";
      this.append(fill);
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Detailed explanation of JS code:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firstly, create the variables on which we are making DOM 
 changes.&lt;/li&gt;
&lt;li&gt;On Fill box, we have two functions &lt;strong&gt;dragStart&lt;/strong&gt; and 
 &lt;strong&gt;dragEnd&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;On Empty box, we have &lt;strong&gt;dragOver&lt;/strong&gt;, &lt;strong&gt;dragEnter&lt;/strong&gt;, 
 &lt;strong&gt;dragLeave&lt;/strong&gt;, &lt;strong&gt;drop&lt;/strong&gt; functions.&lt;/li&gt;
&lt;li&gt;These functions are helpful in giving you an idea on drag 
 and drop operations.&lt;/li&gt;
&lt;li&gt;We have to append the respective classes i.e., empty, fill 
 classes while performing drag and drop on respective boxes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Finally, the &lt;strong&gt;Live demo&lt;/strong&gt; of &lt;strong&gt;output&lt;/strong&gt; will be:
&lt;/h2&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/Day-21-Drag-N-Drop-d6qi5"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;h4&gt;
  
  
  Github Link: &lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/nerdfswd"&gt;
        nerdfswd
      &lt;/a&gt; / &lt;a href="https://github.com/nerdfswd/Day-21-Drag-N-Drop"&gt;
        Day-21-Drag-N-Drop
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Day-21 Drag N Drop. Created with CodeSandbox
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Day-21-Drag-N-Drop&lt;/h1&gt;
&lt;p&gt;Created with CodeSandbox&lt;/p&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/nerdfswd/Day-21-Drag-N-Drop"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;/h4&gt;


&lt;h4&gt;
  
  
  Connect me at &lt;a href="https://twitter.com/nerd_fswd"&gt;https://twitter.com/nerd_fswd&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Hope you liked the project!!&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Today's Pinch of Motivation:
&lt;/h4&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    When you're high on emotion
    And you're losing your focus
    And you feel too exhausted to pray
    Don't get lost in the moment
    Or give up when you're closest
    All you need is somebody to say
    It's okay not to be okay
    It's okay not to be okay
    When you're down and you feel ashamed
    IT'S OK NOT TO BE OK!!
&lt;/code&gt;&lt;/pre&gt;



</description>
      <category>javascript</category>
      <category>50projects50days</category>
      <category>day21</category>
    </item>
  </channel>
</rss>
