Weave.js

Zoom In Tool

Increases one step the stage zoom level

Zoom In Tool action on use on the Weave.js showcase

Introduction

This action allows users to incrementally zoom into the canvas, providing a more detailed view of the content. It adjusts the Stage’s scale smoothly and centers the zoom on the current viewport or a specific focal point.

Dependencies

This action needs registered on the Weave instance the following element:

Usage

Import the Action

Start by importing the action:

import { WeaveZoomInToolAction } from "@inditextech/weave-sdk";

Register the Action

Then register the action on the Weave class instance.

const instance = new Weave({
  ...
  actions: [
    ...,
    new WeaveZoomInToolAction(), 
  ]
})

Setup the action trigger

Setup on a button or any element on the UI the user can interact with on the action event:

instance.triggerAction("zoomInTool");

For example on a button on React:

import React from "react";
import { useWeave } from "@inditextech/weave-react";

const MyZoomInToolTriggerComponent = () => {
  const instance = useWeave((state) => state.instance);

  const triggerTool = React.useCallback(() => {
    instance.triggerAction("zoomInTool");
  }, [instance]);

  return <button onClick={triggerTool}>Zoom In Tool</button>;
};

Trigger the action

Finally a final user trigger the UI element that launches the action.


When triggered increases the zoom level of the canvas by one step.