I would probably try the same but with some short ...
# kvision
r
I would probably try the same but with some short
setTimeout()
delay
t
It works with timeout(), thanks. I am thinking where would be the best place to persist scrollbar position before removing the component from DOM to be able to restore it when the component is inserted back again.
r
No idea how your code is organized, but if it is the same component it would be best to keep this info in the component itself.
t
I would, but when to get the value? I would put it in a hook beforeRemove() if it existed.
something like:
Copy code
var latestScrollPosition: Double = 0

fun beforeRemove() {
    val element = getElement()
    latestScrollPosition = element.scrollTop
}
Finally I used scroll event:
Copy code
onEvent {
  scroll = {
    latestScrollPosition = (getElement() as HTMLElement).scrollTop
  }
}