Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ScrollZoom

A simple scroll to zoom handler

import { PanHandler } from 'pan-handler/PanHandler.js';
import { ScrollZoom } from 'pan-handler/plugins/ScrollZoom.js';

const ctx = document.getElementById('myCanvas').getContext('2d');
const panHandler = new PanHandler(ctx, PAN_OPTIONS);

const clearAndDraw = () => {
    panHandler.clear();
    // Your draw logic here...
};

const scrollZoom = new ScrollZoom((scaleDiff) => {
    panHandler.incrementZoom(scaleDiff);
    clearAndDraw();
});
scrollZoom.addTarget(ctx.canvas);

Hierarchy

  • ScrollZoom

Index

Constructors

Methods

Constructors

constructor

Methods

addTarget

  • addTarget(target: HTMLElement): void
  • Attach wheel handlers to an element. When that element is mousewheeled the OnZoom callback will fire

    You may call addTarget multiple times with different elements to attach handlers to multiple elements.

    Parameters

    • target: HTMLElement

    Returns void

Generated using TypeDoc