# How to find the DOM node path from Pos

**URL:** https://discuss.prosemirror.net/t/how-to-find-the-dom-node-path-from-pos/159
**Category:** Uncategorized
**Created:** [February 4, 2016, 11:04am UTC](https://discuss.prosemirror.net/t/how-to-find-the-dom-node-path-from-pos/159 "2016-02-04T11:04:13Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![whoisterencelee](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/w/97f17d/32.png) [@whoisterencelee](https://discuss.prosemirror.net/u/whoisterencelee)
#### Post date: [February 4, 2016, 11:04am UTC](https://discuss.prosemirror.net/t/how-to-find-the-dom-node-path-from-pos/159/1 "2016-02-04T11:04:13Z")

</div>

Given a document Pos(ition) how can I find the DOM node path?

---

<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: [February 9, 2016, 8:34pm UTC](https://discuss.prosemirror.net/t/how-to-find-the-dom-node-path-from-pos/159/2 "2016-02-09T20:34:40Z")

</div>

What do you want to do with the DOM node? Changing them is unlikely to work.

---

<div class="post-metadata">

### Author: ![whoisterencelee](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/w/97f17d/32.png) [@whoisterencelee](https://discuss.prosemirror.net/u/whoisterencelee)
#### Post date: [February 11, 2016, 12:53am UTC](https://discuss.prosemirror.net/t/how-to-find-the-dom-node-path-from-pos/159/3 "2016-02-11T00:53:58Z")

</div>

Found DOMFromPos in edit/dompos.js .

I am trying to track the actual pixel location of the markRange from/to position, seems when I try to use the document “transform” event to do this, strange things happen, the positions gets shifted, maybe the positions have not yet settled? Perhaps I need to throttle the event handler.

Which event should I listen to properly tracking markRange Positions? Maybe the markRange should signal a transform?

---

<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: [February 11, 2016, 9:10am UTC](https://discuss.prosemirror.net/t/how-to-find-the-dom-node-path-from-pos/159/4 "2016-02-11T09:10:29Z")

</div>

You can use the `coordsAtPos` method to find the screen coordinates at a position. But display updates are asynchronous, so you should probably wait for a `draw` event – when `transform` fires, the changes haven’t been flushed to the display yet.

---

<div class="post-metadata">

### Author: ![whoisterencelee](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/w/97f17d/32.png) [@whoisterencelee](https://discuss.prosemirror.net/u/whoisterencelee)
#### Post date: [February 21, 2016, 7:54am UTC](https://discuss.prosemirror.net/t/how-to-find-the-dom-node-path-from-pos/159/5 "2016-02-21T07:54:06Z")

</div>

The draw event mostly works, but should markRange fire some sort of movement/ change signal, since it’s the only way for external programs to track positions?

---

<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: [February 22, 2016, 10:18am UTC](https://discuss.prosemirror.net/t/how-to-find-the-dom-node-path-from-pos/159/6 "2016-02-22T10:18:21Z")

</div>

You should reposition after every `"draw"` event, since even if the position towards a range stays the same, the content above it might have changed size so its pixel position isn’t guaranteed to be the same.
