Do you have an issue with a specific file(s)? No
Can you reproduce using one of our samples or online demos? No
Are you using the WebViewer server? Yes
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? No
Is your issue related to annotations? No
Please give a brief summary of your issue:
I want to implement a function that updates the mouse wheel behavior based on a selected condition. When the condition changes, it should dynamically switch between zooming on mouse wheel and normal scrolling.
if (isZoomChecked) {
PartialApryse.EnableMouseWheelZoom(UI, documentViewer);
}
if (isScrollChecked) {
PartialApryse.EnableScrollOnMouseWheel(UI);
}
EnableMouseWheelZoom: function (instance, documentViewer) {
instance.addEventListener('mousewheel', (event) => {
event.preventDefault();
const currentZoom = documentViewer.getZoomLevel();
const zoomFactor = 1.1;
if (event.deltaY < 0) {
documentViewer.zoomTo(currentZoom * zoomFactor);
}
else {
documentViewer.zoomTo(currentZoom / zoomFactor);
}
});
},
EnableScrollOnMouseWheel: function (instance) {
// Remove previous bound handler if present
instance.removeEventListener('mousewheel', this._mouseWheelHandler);
// Set empty handler (no preventDefault)
this._mouseWheelHandler = function () {
// Allow natural scrolling
};
instance.addEventListener('mousewheel', this._mouseWheelHandler);
},
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 you want to switch between zooming and scrolling functionalities using the mouse wheel in Apryse’s WebViewer. This can be done by managing event listeners based on a condition. You need to ensure that the event listeners are properly added and removed to achieve dynamic switching seamlessly.
Some things you can try:
Initialize the WebViewer instance and set up your condition checks for zooming and scrolling.
Use addEventListener and removeEventListener to toggle between zooming and scrolling functionalities.
Ensure that each time a condition changes, the previous event listener is removed before adding the new one.
Within EnableMouseWheelZoom, prevent the default scrolling behavior and apply zoom based on the direction of the mouse wheel scroll.
For EnableScrollOnMouseWheel, allow the default behavior by not preventing the default action.