# Prosemirror-view: scrollToSelection and resetScrollPos

**URL:** <https://discuss.prosemirror.net/t/prosemirror-view-scrolltoselection-and-resetscrollpos/909>\
**Category:** Uncategorized\
**Created:** [August 1, 2017, 3:11pm UTC](https://discuss.prosemirror.net/t/prosemirror-view-scrolltoselection-and-resetscrollpos/909 "2017-08-01T15:11:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JCHollett](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@JCHollett](https://discuss.prosemirror.net/u/JCHollett)\
**Post date:** [August 1, 2017, 3:11pm UTC](https://discuss.prosemirror.net/t/prosemirror-view-scrolltoselection-and-resetscrollpos/909/1 "2017-08-01T15:11:38Z")

</div>

Hi,

I’m working with prosemirror in a project where we need more control over scrolling after transactions take place. The issue for what I’m doing is that if I want to take more control over the view.dom scrolling I need to do all of that outside of the view: update. This requires references various amounts of tracking outside of the prosemirror api.

The closest you can get to updateState is by overriding the dispatchTransaction prop on the EditorView. So what would help for me is if there was a way to trigger off the if (scrollToSelection) and else if (oldScrollPos). The most useful place for our customized scrolling is to use a tr.setMeta and save it in the plugin for view.update. Unfortunately, if the selection changes it likes to move the screen around.

We are trying to emulate some functionality as part of our project that is not natively supported and the selection position is important but, the way that scrolling is handled with prosemirror-view is not easy to override.

Also, It would be nice to be able to decide if we want the view to update where the caret is as well, or override/disable that functionality entirely and substitute our own. I’m not sure if I’m missing something here either.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 1, 2017, 4:05pm UTC](https://discuss.prosemirror.net/t/prosemirror-view-scrolltoselection-and-resetscrollpos/909/2 "2017-08-01T16:05:34Z")

</div>

> [@JCHollett](#):
>
> what would help for me is if there was a way to trigger off the if (scrollToSelection) and else if (oldScrollPos).

I’m not sure you’d want to turn off the second – a redraw may potentially collapse the content and then recreate it, moving your scroll position back to zero from anywhere. Even for custom scroll behavior, you’d want the old scroll position as a baseline, I expect.

Would just having a way to override/disable scrolling the selection into view after a transaction work?

---

<div class="post-metadata">

**Author:** ![JCHollett](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@JCHollett](https://discuss.prosemirror.net/u/JCHollett)\
**Post date:** [August 1, 2017, 4:57pm UTC](https://discuss.prosemirror.net/t/prosemirror-view-scrolltoselection-and-resetscrollpos/909/3 "2017-08-01T16:57:36Z")

</div>

Yes. Just the ability to tell the view to not scroll or override for a particular updateState is more than sufficient.

---

<div class="post-metadata">

**Author:** ![JCHollett](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@JCHollett](https://discuss.prosemirror.net/u/JCHollett)\
**Post date:** [August 3, 2017, 11:29am UTC](https://discuss.prosemirror.net/t/prosemirror-view-scrolltoselection-and-resetscrollpos/909/4 "2017-08-03T11:29:31Z")

</div>

For now I will rig up something simple and workable in the dispatchTransaction prop for the editorview. I hope you might consider my suggestion, even if it is low priority.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 5, 2017, 8:58am UTC](https://discuss.prosemirror.net/t/prosemirror-view-scrolltoselection-and-resetscrollpos/909/5 "2017-08-05T08:58:41Z")

</div>

Does [this patch](https://github.com/ProseMirror/prosemirror-view/commit/dcbf44a3981f299cf973c1eb1c678dc6d17ed02d) help for you?

---

<div class="post-metadata">

**Author:** ![JCHollett](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@JCHollett](https://discuss.prosemirror.net/u/JCHollett)\
**Post date:** [August 11, 2017, 12:43pm UTC](https://discuss.prosemirror.net/t/prosemirror-view-scrolltoselection-and-resetscrollpos/909/6 "2017-08-11T12:43:44Z")

</div>

Also yes, We’re using it now, Thank you very much for that. Simply calling scrollIntoView now is sufficient to trigger that prop it seems.
