C
C
campus12018-06-14 10:21:15
JavaScript
campus1, 2018-06-14 10:21:15

How to return to the clicked place?

Hello. I have a table with n-number of rows.
5b221597edfcf770001657.png
I click on any of the lines and I am transferred to the route/matreix/some/:id

cancel = () => browserHistory.push(`/matreix/some`)

Since the table is large, then if, for example, I click on the element below and then click on the button Cancel, it will transfer me to the top of the table to the first element, and I want something to transfer me to the height (where the element is located) where I clicked.
How can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
campus1, 2018-06-14
@campus1

Solved the problem like this

componentDidMount() {
    window.addEventListener('scroll', this.handleScroll);
}

componentWillUnmount() {
    window.removeEventListener('scroll', this.handleScroll);
}

handleScroll = (event) => {
    let scrollTop = event.srcElement.body.scrollTop,
        itemTranslate = Math.min(0, scrollTop/3 - 60);

        console.log(itemTranslate);

    this.setState({
      transform: itemTranslate
    });
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question