title: How to construct a mathematical formula corresponding to the index with the presented values
body: <p>I have this function to centralize a item in <code>Flatlist</code> (horizontal):</p>
  
  <pre><code>centralizeItem = (index) =&gt; {
   const WIDTH = scale(95)
   let centerSize
  
   if (index === 0) centerSize = (WIDTH*1.5) * -1
  
   if (index === 1) centerSize = (WIDTH/2) * -1
  
   if (index === 2) centerSize = (WIDTH/2)
  
   if (index === 3) centerSize = (WIDTH*(index/2))
  
   if (index === 4) centerSize = (WIDTH*(index/2+0.5)) // 2.5
  
   if (index === 5) centerSize = (WIDTH*(index/2+1)) // 3.5
  
   if (index === 6) centerSize = (WIDTH*(index/2+1.5)) //4.5
  
    return centerSize
  }
  </code></pre>
  
  <p>This formula return a Offset value to scroll in y-value using </p>
  
  <pre><code>this.refs.listRef.scrollToOffset({offset: this.centralizeItem(index) })
  </code></pre>
  
  <p>The above code fires when the item is selected</p>
  
  <p>But, the <code>Flatlist</code> render a lot of data, not just 7 index, and this formula are impracticable.</p>
  
  <p>I need a formula that follow the variations above in the function</p>