src/SearchBar.js
/**
   * Updates the map focus and search bar counter for when buttons are clicked.
   * @param {number} current - index of current search result
   */
Updates the map focus and search bar counter for when buttons are clicked.
@param {number} current - index of current search result
Updates the map focus and search bar counter for when buttons are clicked . @param { number } current - index of current search result
update (current) {
    this.setState({
      current,
      counter: `${current + 1}/${this.state.results.length}`
    })
    var r = this.state.results[current]
    if (r.type === 'reaction') {
      this.props.map.zoom_to_reaction(r.reaction_id)
      this.props.map.highlight_reaction(r.reaction_id)
    } else if (r.type === 'metabolite') {
      this.props.map.zoom_to_node(r.node_id)
      this.props.map.highlight_node(r.node_id)
    } else if (r.type === 'text_label') {
      this.props.map.zoom_to_text_label(r.text_label_id)
      this.props.map.highlight_text_label(r.text_label_id)
    } else {
      throw new Error('Bad search index data type: ' + r.type)
    }
  }
update ( current ) { this . setState ( { current , counter : ` ${ current + 1 } ${ this . state . results . length } ` } ) var r = this . state . results [ current ] if ( r . type === 'reaction' ) { this . props . map . zoom_to_reaction ( r . reaction_id ) this . props . map . highlight_reaction ( r . reaction_id ) } else if ( r . type === 'metabolite' ) { this . props . map . zoom_to_node ( r . node_id ) this . props . map . highlight_node ( r . node_id ) } else if ( r . type === 'text_label' ) { this . props . map . zoom_to_text_label ( r . text_label_id ) this . props . map . highlight_text_label ( r . text_label_id ) } else { throw new Error ( 'Bad search index data type: ' + r . type ) } }
Updates the map focus and search bar counter for when buttons are clicked.
Updates the map focus and search bar counter for when buttons are clicked .