updateIndex(offset, dir) {

    let state = this.state
    let index = state.index
    let diff = offset[dir] - state.offset[dir]
    let step = dir == 'x' ? state.width : state.height

    // Do nothing if offset no change.
    if(index > 0 && !diff) {
      return;
    }

    // Note: if touch very very quickly and continuous,
    // the variation of `index` more than 1.
    index = index + diff / step

    if(this.props.loop) {
      if(index <= -1) {
        index = state.total - 1
        offset[dir] = step * state.total
      }
      else if(index >= state.total) {
        index = 0
        offset[dir] = step
      }
    }

    this.setState({
      index: index,
      offset: offset,
    })

    this.props.onSelectedIndexChange && this.props.onSelectedIndexChange(index, offset);
  }
Update index after scroll
@param  {object} offset content offset
@param  {string} dir    'x' || 'y'