Skip to main content

SnappingExtension

The SnappingExtension is a Design Extension which provides a public API for computing the possible snapping points for a panels items, centerpoint, and masks. This Extension automatically computes changes as the underlying data changes such that the results remain accurate while an interaction is happening.

Extension Dependencies

The following extensions should be registerd to the Interactive Design Engine in order for this extension to function as intended:

  • IDAItemLayoutExtension
    • ItemSelectionExtension
    • ItemPreviewExtension
  • ItemSelectionExtension
  • PanelLayoutExtension
  • ItemTemplateExtension
    • ItemMetadataExtension

In addition, the SnappingExtension may optionally be injected with a designRequirements dependency which can be used to provide the SnappingExtension with Mask data such as Bleed, Trim and Safe masks in order to allow an extension to snap to those snapping lines.

You can provide the extension this dependency by:

    const exampleEngine = new InteractiveDesignEngine(...);
const exampleDesignRequirements = {...};

exampleEngine.designExtensionSystem.injector.provide('designRequirements', exampleDesignRequirements);

SnappingExtension Public API

PropertyTypePurpose
snappingThresholdPxobservable number;The threshold used to calculate the closest snapline for the current selection of items.
setSnappingThresholdaction (number) => void;A method to set the snappingThresholdPx value.
showSnapLinesobservable boolean;A value which can be used to show or hide the target snap lines.
setShowSnapLinesaction (boolean) => void;A method to set the showSnapLines value.
isEnabledobservable boolean;Tracks whether or not snapping is enabled or disabled.
setIsEnabledaction (boolean) => void;A method to set the isEnabled value.
excludedSnapTargetsobservable ExcludableSnapTargets;Tracks which snapping targets should be excluded when computing targetSnapLines.
setExcludeSnapTargetsaction (ExcludableSnapTargets) => void;A method to set the excludedSnapTargets value.
showSnapBoxcomputed boolean;Computes the display status of a selection's SnapBox. True when an item has rotation, is text or more than one is selected.
selectedSnapBoxcomputed ItemSnapBox;Computes the SnapBox of a selection of items. The SnapBox is an axis aligned bounding box comprised of the selection.
targetSnapLinescomputed TargetSnapLines;Computes the target horizontal and vertical SnapLine values closest to the current selection's snapping points.