search

Home  >  Q&A  >  body text

Use mouse wheel for page zoom, click and drag to pan the page

How to use the mouse wheel to create scrolling and panning effects for the entire page? Basically just like any 2D editor, scroll to zoom and click and drag to pan, but for the entire body.

I can't find any information about it online.

P粉308783585P粉308783585268 days ago358

reply all(1)I'll reply

  • P粉466643318

    P粉4666433182024-03-27 09:51:01

    If you don't know where to start, you'll quickly hit a wall because knowing where to start is the easy part. Here's a rough guide:

    1. Add an event listener to the wheel event (Learn how](https://stackoverflow.com/a/51276012/104380))
    2. Starting from the initial (current) zoom value, calculate the increment of wheel events and update %

      reply
      0
  • Cancelreply