Weave.js

Zoom Out Tool

Decreases one step the stage zoom level

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

Introduction

This action allows users to incrementally zoom out the canvas, providing a more general 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 { WeaveZoomOutToolAction } from "@inditextech/weave-sdk";

Register the Action

Then register the action on the Weave class instance.

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

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("zoomOutTool");

For example on a button on React:

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

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

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

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

Trigger the action

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


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