Zoom resets moveable line in Shiny app

In the solution to this post (link below, by nirgrahamuk) about creating moveable lines with plotly, if you zoom in, the entire plot resets and the moved vertical line goes back to the origin. How should this be modified so the moved line stays where it was last dragged even when the zoom window changes on the plot? I ran the code from the posted solution as is:

Thanks for any help on this!