0

I have a function that needs to run each time the scrollIntoView finishes moving the scrollbar. How could I do that?

Daniel
  • 1
  • 1
  • Why? What is the function doing? – Andreas Nov 29 '21 at 12:06
  • What have you tried so far to solve this on your own? – Andreas Nov 29 '21 at 12:06
  • @Andreas, I have an image slider with a progress bar under it and the function is calculating the Index of the image in the center based on scrollbar values. Then if I have 12 images and the scrollbar is showing that I'm under element 6, then I highlight the 6-th element of the progress bar. User can also click directly on a progress bar element to scroll directly to an image. – Daniel Nov 29 '21 at 12:14
  • I've tried setting a state to know if the user scrolled from the progress bar by click or from a normal container scroll because the calculation is different for each of these 2 interactions but state change is happening before the end of scroll resulting in undesired side effect. I've also tried with a setTimeout but is unreliable. – Daniel Nov 29 '21 at 12:16
  • 1
    [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) -> Add a [mcve] with the relevant information _in the question itself_ and not as a comment. – Andreas Nov 29 '21 at 12:18
  • There is too much code to provide that and I'm under NDA. I just want to know how can I run something after a scroll end. For example React native has such event `scrollEnd` javascript doesn't have sadly. – Daniel Nov 29 '21 at 12:20
  • Welcome to Stack Overflow! Visit the [help], take the [tour] to see what and [ask]. Please first ***>>>[Search for related topics on SO](https://www.google.com/search?q=detect+scrollend+scrollintoview+site%3Astackoverflow.com)<<<*** and if you get stuck, post a [mcve] of your attempt, noting input and expected output using the [`[<>]`](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Nov 29 '21 at 12:25

0 Answers0