Weave.js

WeaveFitToSelectionToolAction

Set the zoom level so all the selected nodes are entirely visible on the screen

Overview

The WeaveFitToSelectionToolAction class that automatically zooms and pans the canvas to fit the currently selected nodes within the visible viewport. It helps users focus on specific elements of their work quickly, especially in large or complex canvases.

This action is the “fit to selection” counterpart of the broader WeaveFitToScreenToolAction, offering precise control and workflow efficiency.

The class extends the WeaveAction class.

Name

This action name property value is fitToSelectionTool.

Import

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

Instantiation

new WeaveFitToSelectionToolAction();

TypeScript types

type WeaveFitToScreenToolActionParams = {
  previousAction: string;
  smartZoom?: boolean;
};

Trigger function params

trigger(cancelAction: () => void, params?: WeaveFitToSelectionToolActionParams): void;

For WeaveFitToSelectionToolActionParams:

Property Type Required Description

previousAction

string

Required

The action to trigger after the fit-to-selection action is completed.

smartZoom

boolean

If true, when fit-zooming we will only tri to zoom if nodes bounding box is overflowing stage bounding box, if not, we just center the stage on the nodes selected.