Pan and Zoom
Allows you to zoom in on an element.
new zoom(zoomOptions)Basic implementation
Section titled “Basic implementation”const grid = new zoom({ element: '.grid' });zoomOptions
Section titled “zoomOptions”interface ZoomOptions { element: string, minZoom?: number, maxZoom?: number, zoomFactor?: number, onZoom?: Function}element
Section titled “element”Type:
type element = stringThe element selector.
minZoom
Section titled “minZoom”Type:
type minZoom = numberdefault: 0.1
How much you can zoom out of the element.
maxZoom
Section titled “maxZoom”Type:
type maxZoom = numberdefault: Inifinity
How much you can zoom in on the element.
zoomFactor
Section titled “zoomFactor”Type:
type zoomFactor = numberdefault: 0.1
By how much to zoom in or out of the element.
onZoom
Section titled “onZoom”Type:
type onZoom = () => void;Executes when the element zooms in or out.
Properties
Section titled “Properties”actionName readonly
Section titled “actionName ”Type:
type actionName = stringThe name of the action that can be used to programmatically zoom the element.
touchEnabled
Section titled “touchEnabled”Type:
type touchEnabled = booleanEnables or disables touch events. Default is false.
Methods
Section titled “Methods”deinit()
Section titled “deinit()”Removes the event listeners and disables the zoom functionality.
Actions
Section titled “Actions”You are able to zoom elements using actions. Since every zoom action is unique you can do the following:
const element = new zoom({ element: '.grid' });
actions.execute(element.actionName, {x: 100, y: 100, zoomDirection: -1});Where you need to provide the x and y coordinates of the element, where you want to zoom to and the zoomDirection which can be -1 for zoom out and 1 for zoom in.
interface ZoomAction { x: number; y: number; zoomDirection: number;}