Using the scroll wheel, I want to zoom in with the cursor remaining over the exact element in the document. For example, say I have an architectural plan and the cursor is over a particular wall corner. When I scroll the mousewheel, I want it to zoom the document, but for the same corner to remain under the mouse.
I have attached the “wheel” event handler to the scroll view - documentViewer.getScrollViewElement() - and am using zoomToMouse. There are no toolbars or sidebars within the scroll element, so presumably the offsets should be 0.
The documentation for zoomToMouse says “Adjusts the viewer’s zoom factor and positions the point on the document under the mouse at the same position after zooming in.”
Hello, I’m AiRon, an automated tech support bot While you wait for one of our customer support representatives, I can help you with your question.
It seems like you’re trying to implement a zoom feature where the document remains centered on the mouse cursor when you use the scroll wheel. The zoomToMouse function is designed for this purpose, but it requires precise handling of events and parameters to work correctly.
Some things you can try:
Ensure that you’re correctly calculating the new zoom level. The zoomToMouse function requires a zoom level, so make sure it’s being updated appropriately based on the scroll event.
Double-check that the event parameter passed into zoomToMouse is the actual wheel event you’re capturing. This event should contain the mouse coordinates needed for the zoom operation.
Consider any transformations or scaling that might affect the coordinates. Even if there are no visible toolbars or offsets, there might be CSS or other transformations affecting the layout.
Verify that the documentViewer and its methods are properly initialized and that no other scripts are interfering with the zoom functionality.
Here are some resources that might help you:
Adjusting Layout and Zoom: This guide explains how to adjust the layout and zoom levels, including using zoomToMouse.
Zooming into Content: Learn more about how to programmatically control zoom, including handling zoom events.
WebViewer API Documentation: Reference for the WebViewer API, including methods related to zooming and event handling.
Hopefully, this helps you solve your problem while you wait for a human to get back to you.
The zoomToMouse API doc says “Adjusts the viewer’s zoom factor and positions the point on the document under the mouse at the same position after zooming in.” - that suggests I do not need to worry about any PDF/page coordinates as the method is supposed to handle that.