# How to Pan while tracing by pressing and holding the left click of the mouse

**URL:** <https://pdfjs.community/t/how-to-pan-while-tracing-by-pressing-and-holding-the-left-click-of-the-mouse/531>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [February 22, 2021, 12:12pm UTC](https://pdfjs.community/t/how-to-pan-while-tracing-by-pressing-and-holding-the-left-click-of-the-mouse/531 "2021-02-22T12:12:58Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![kiran.patil](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kiran.patil](https://pdfjs.community/u/kiran.patil)\
**Post date:** [February 22, 2021, 12:12pm UTC](https://pdfjs.community/t/how-to-pan-while-tracing-by-pressing-and-holding-the-left-click-of-the-mouse/531/1 "2021-02-22T12:12:58Z")

</div>

**PDF.js Express Version**  
“name”: “webviewer”,  
“description”: “PDFJS Express”,  
“version”: “7.2.0”,

**Detailed description of issue**

I want to enable panning while tracing/drawing any tool like (AnnotationCreatePerimeterMeasurement) and (AnnotationCreateAreaMeasurement). I have used setToolMode to enable tracing. Now while tracing, User should be able to zoom and pan while tracing.

I have got some information regarding this. So Can you give me some working snippet of this idea because it didn’t work as expected. -

> You can implement the auto scrolling functionality by listening to the [mouseMove](https://www.pdftron.com/api/web/CoreControls.DocumentViewer.html#event:mouseMove__anchor) event on the docViewer. The idea is to listen to this event, and in the event handler you can check if currently the mouse position is near the edge of the viewport. If this is the case, you can call [docViewer.getScrollViewElement](https://www.pdftron.com/api/web/CoreControls.DocumentViewer.html#getScrollViewElement) to get the scroll container and set its scrollTop or scrollLeft to scroll.

**Expected behaviour**  
User should be able to pan while tracing annotations like Perimeter and area tool.

**Does your issue happen with every document, or just one?**  
Every Document

**Link to document**  
Any Pdf document.

**Code snippet**  
This works but only when mouse goes close to viewer’s border, but I want to enable panning even if it is not close to the webviewer’s border. User should be free to pan while tracing.

` instance.docViewer.on('mouseMove', e => {`  
` const docContainer1 = instance.iframeWindow.document.querySelector('[data-element="documentContainer"]');`  
` docContainer1.scrollTop = e.y;`  
` docContainer1.scrollLeft = e.x;`  
` });`

---

_[View the full topic](https://pdfjs.community/t/how-to-pan-while-tracing-by-pressing-and-holding-the-left-click-of-the-mouse/531)._
