<?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: shrek-7</title>
    <description>The latest articles on DEV Community by shrek-7 (@shrek7).</description>
    <link>https://dev.to/shrek7</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%2F185529%2F92c3dce3-af01-48a8-a556-d7cd1e4a0639.png</url>
      <title>DEV Community: shrek-7</title>
      <link>https://dev.to/shrek7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shrek7"/>
    <language>en</language>
    <item>
      <title>Text animation with CSS - strike through line</title>
      <dc:creator>shrek-7</dc:creator>
      <pubDate>Tue, 20 Oct 2020 14:28:32 +0000</pubDate>
      <link>https://dev.to/shrek7/text-animation-with-css-strike-through-line-ea6</link>
      <guid>https://dev.to/shrek7/text-animation-with-css-strike-through-line-ea6</guid>
      <description>&lt;p&gt;Hello folks!&lt;br&gt;
I often love to play around with CSS and try out things whenever I'm free. I always feel animations with just CSS is highly underrated and can be used to achieve 60 fps animations without any JS involved.&lt;br&gt;
I have tried to create a very simple animation, a strike through line, a line passes through a text and the characters in that text are alternatively overlapped onto the line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
For the HTML part we only need a parent container,  it will contain the &lt;code&gt;text&lt;/code&gt; that we want to show and the another empty &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; which will be used as the &lt;code&gt;line&lt;/code&gt; we want to animate. &lt;br&gt;
Notice that the &lt;code&gt;text&lt;/code&gt; is not just a string but in a form of a list, so that we can change the &lt;code&gt;z-index&lt;/code&gt; of individual characters.

&lt;p&gt;&lt;strong&gt;CSS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Styling of the parent container&lt;/strong&gt;&lt;br&gt;
Just some general styling, &lt;code&gt;height, width, alignment&lt;/code&gt; also &lt;code&gt;position&lt;/code&gt; as &lt;code&gt;relative&lt;/code&gt;, it will be used the position the &lt;code&gt;line&lt;/code&gt; with respect to parent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Styling of Text&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;align horizontally with flex&lt;/li&gt;
&lt;li&gt;Remove default styling of &lt;code&gt;li&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;z-index&lt;/code&gt; set to 1&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;z-index&lt;/code&gt; of alternative elements set to 3 ( using pseudo class &lt;code&gt;nth-child(2n + 1) or nth-child(2n)&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;position:relative&lt;/code&gt; - &lt;code&gt;z-index&lt;/code&gt; won't work without it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Styling of line&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;position it &lt;code&gt;absolute&lt;/code&gt; with respect to the parent element, half way from the top.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;width&lt;/code&gt; to be some default value, we will animate width of the line from some initial value lets say &lt;code&gt;5vw&lt;/code&gt; to final value '100vw'.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;z-index&lt;/code&gt; should be set as 2, since the &lt;code&gt;li&lt;/code&gt; elements of the text is given value 1 and 3 alternatively.&lt;/li&gt;
&lt;li&gt;animation, to increase the &lt;code&gt;width&lt;/code&gt; of &lt;code&gt;line&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Link to Sandbox&lt;br&gt;
&lt;a href="https://codesandbox.io/s/strike-through-line-animation-q7x9m"&gt;https://codesandbox.io/s/strike-through-line-animation-q7x9m&lt;/a&gt;&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/strike-through-line-animation-q7x9m"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Happy coding ♥ !&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>javascript</category>
      <category>web</category>
    </item>
    <item>
      <title>JavaScript Reduce method</title>
      <dc:creator>shrek-7</dc:creator>
      <pubDate>Mon, 16 Mar 2020 14:28:02 +0000</pubDate>
      <link>https://dev.to/shrek7/javascript-reduce-method-2dpa</link>
      <guid>https://dev.to/shrek7/javascript-reduce-method-2dpa</guid>
      <description>&lt;p&gt;I have been a fan of map and filter but never bothered to look into how we can use reduce to simplify and minimise the lines of code ( " make it difficult for others ").&lt;/p&gt;

&lt;p&gt;This is what the documentation says,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;array.reduce( callback(accumulator, currentValue, currentIndex, arr), initialValue);&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;callback : to execute on each element in the array (except for the first, if no initialValue is supplied )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;accumulator: It recieves the return value of the callback, its the value returned from the last invocation of callback or initialValue.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;currentValue: Current value of the array being processed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;currentIndex: Index of the current value of the array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;arr: The entire array on which we are calling reduce.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;initialValue: Value as a first argument to call the callback for the first time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a small snippet to reverse a string using reduce method. We will loop through the code and dive deeper to see how it works.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Reverse a string
var stringToReverse= "fiction";

var arrList = stringToReverse.split(''); 
// ["f", "i", "c", "t", "i", "o", "n"]

var getReverse = function( total, currentValue, currentIndex, arr ) {
    let valueToBeReturned = currentValue + total;
    return valueToBeReturned;
}

var b = arrList.reduce( getReverse, '#' );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So according to the docs, here "callback" is getReverse() function, "initialValue" is '#'.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;first Iteration&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hEt5zOKt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w3nh8ani7esvq1lzt9l7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hEt5zOKt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w3nh8ani7esvq1lzt9l7.png" alt="Iteration 1"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;accumulator gets a value: '#' this is the initial value that I have passed to the reduce method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;currentValue : 'f' // first element of the array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;valueToBeReturned: Its just concatenated value of currentValue and accumulator. ('f#' ).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;lets see what next.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;second iteration&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jotn6zLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4vbuy7piyscpnw1rajcy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jotn6zLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4vbuy7piyscpnw1rajcy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;third iteration&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oHfyV949--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rov19xvoem0v7ujdxdfw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oHfyV949--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rov19xvoem0v7ujdxdfw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;fourth iteration&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vHcHrNPL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c8xqttnyk60wkkg45wjo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vHcHrNPL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c8xqttnyk60wkkg45wjo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;fifth iteration&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W4KVfdRV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nejen230bubr09rkpb3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W4KVfdRV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nejen230bubr09rkpb3o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;sixth iteration&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wSc9-meg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s8x23jp3v3f9j3sesb82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wSc9-meg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s8x23jp3v3f9j3sesb82.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*last iteration&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f-vRo37E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bs6ao22ixh7ez9iceyqn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f-vRo37E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bs6ao22ixh7ez9iceyqn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the shortened code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var stringToReverse= "fiction";
var arrList = stringToReverse.split(''); // ["f", "i", "c", "t", "i", "o", "n"]
var getReverse = (reverse, currentValue) =&amp;gt; currentValue + reverse;
var reversedStr = arrList.reduce( getReverse, '' );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats it folks. How about you go further and share about what happens if we don't pass the "initialValue" ? What does accumulator gets in that case ?&lt;br&gt;
Also , feedback would be valuable.&lt;br&gt;
Cheers!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce"&gt;MDN web docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>functional</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
