title: Horizontal scrollview snapping react native
body: <p>Hi I am trying to achieve <code>scrollview</code> snap to center 
  like below <code>gif</code> link </p>
  
  <p><a href="https://camo.githubusercontent.com/79f6b2c710949911f76630d9c1c42a349c7d20c4/687474703a2f2f692e696d6775722e636f6d2f364931437648452e676966" rel="noreferrer">Check This Gif</a></p>
  
  <p>But unable to do so. Following is my react native code to achieve this.</p>
  
  <p>or is there any method to scroll to  particular index of scrollview elements like android ?</p>
  
  <p>Any help would be appreciated.
  Thanks in advance</p>
  
  <pre><code>&lt;ScrollView
    style={[styles.imgContainer,{backgroundColor:colorBg,paddingLeft:20}]}
    automaticallyAdjustInsets={false}
    horizontal={true}
    pagingEnabled={true}
    scrollEnabled={true}
    decelerationRate={0}
    snapToAlignment='center'
    snapToInterval={DEVICE_WIDTH-100}
    scrollEventThrottle={16}
    onScroll={(event) =&gt; {
      var contentOffsetX=event.nativeEvent.contentOffset.x;
      var contentOffsetY=event.nativeEvent.contentOffset.y;
  
      var  cellWidth = (DEVICE_WIDTH-100).toFixed(2);
      var cellHeight=(DEVICE_HEIGHT-200).toFixed(2);
  
      var  cellIndex = Math.floor(contentOffsetX/ cellWidth);
  
      // Round to the next cell if the scrolling will stop over halfway to the next cell.
      if ((contentOffsetX- (Math.floor(contentOffsetX / cellWidth) * cellWidth)) &gt; cellWidth) {
        cellIndex++;
      }
  
      // Adjust stopping point to exact beginning of cell.
      contentOffsetX = cellIndex * cellWidth;
      contentOffsetY= cellIndex * cellHeight;
  
      event.nativeEvent.contentOffsetX=contentOffsetX;
      event.nativeEvent.contentOffsetY=contentOffsetY;
  
      // this.setState({contentOffsetX:contentOffsetX,contentOffsetY:contentOffsetY});
      console.log('cellIndex:'+cellIndex);
  
      console.log("contentOffsetX:"+contentOffsetX);
        // contentOffset={{x:this.state.contentOffsetX,y:0}}
    }}
  &gt;
    {rows}
  
  &lt;/ScrollView&gt;
  </code></pre>