ViewConfig Reference

This reference provides complete documentation for the ViewConfig object, which controls the visual appearance and behavior of the Anyline Web SDK scanning interface.

Overview

The ViewConfig defines all visual aspects of the scanning experience:

  • Cutout area: The scanning region where the SDK processes frames

  • Visual feedback: Real-time animations and indicators during scanning

  • UI guidance: Dynamic and static user instructions

  • Overlay styling: Background overlay appearance

init() checks the ViewConfig, as the Mobile SDKs check their view configuration. An unknown option or an invalid value throws InvalidViewConfigError (code 9027), with the path of the option in the message. See InvalidViewConfigError.

ViewConfig Structure

interface ViewConfig {
  // Global overlay styling
  outerColor?: string;                        // Hex RGB (e.g., '000000')
  outerAlpha?: number;                        // Overlay opacity 0-1

  // Cutout stroke animation style
  feedbackAnimationStyle?: 'blink' | 'path';  // Default: 'blink'

  // Cutout definitions (required when no preset is used)
  cutouts?: ICutout[];                        // Array of scanning areas

  // User guidance
  uiFeedback?: {
    dynamic?: UiFeedbackConfig;
    static?: {
      instructionText: string;
    };
  };
}

If you use a preset, cutouts are provided by the preset. When no preset is used, at least one cutoutConfig must be defined in viewConfig.cutouts.

Global Overlay Properties

outerColor

Hex color code for the overlay surrounding the cutout area (6-digit RGB). Transparency is controlled by outerAlpha; the alpha byte of an 8-digit value is ignored, as in the Mobile SDKs. It overrides cutoutConfig.outerColor.

viewConfig: {
  outerColor: '000000'   // Black overlay
}

Common choices include 'FFFFFF' for a light overlay or '1A1A1A' for a dark gray shade.

outerAlpha

Opacity of the overlay from 0 (transparent) to 1 (opaque).

viewConfig: {
  outerAlpha: 0.5   // 50% transparent
}

Increase the value towards 1 for a more opaque overlay, or lower it towards 0 to expose more of the camera feed. It overrides cutoutConfig.outerAlpha. Without any outerColor or outerAlpha, the overlay opacity is 0.65. If only a color is set, it is 0.5.

feedbackAnimationStyle

Controls how the cutout border animates during scanning. This affects the stroke/outline of the scanning area itself.

This is different from scanFeedback.animation, which controls the visual feedback indicator shown when content is detected within the cutout. See Scan Feedback Configuration for details.

viewConfig: {
  feedbackAnimationStyle: 'blink'  // or 'path'
}

Options:

  • 'blink' (default): The cutout border blinks to indicate active scanning

  • 'path': An animated path travels along the cutout border outline

Cutout Configuration

The cutout defines the scanning area. Without a preset, the first cutout must have a cutoutConfig. With a preset, your cutout is merged into the preset’s cutout. A preset supports only one cutout.

ICutout Structure

interface ICutout {
  id?: number | string;                      // > 0 or a non-empty string, unique

  cutoutConfig: {
    // Position
    alignment?: 'top' | 'top_half' | 'center' | 'bottom_half' | 'bottom';
    offset?: { x?: number; y?: number };

    // Size
    width?: number;
    height?: number;
    ratioFromSize?: { width: number; height: number };
    maxWidthPercent?: string;
    maxHeightPercent?: string;

    // Visual styling
    strokeColor?: string;
    inactiveStrokeColor?: string;
    strokeWidth?: number;
    cornerRadius?: number;
    feedbackStrokeColor?: string;

    // Animation
    animation?: 'none' | 'fade' | 'zoom';     // Cutout appear animation
    delay?: number;

    // Overlay, used when the global values are not set
    outerColor?: string;
    outerAlpha?: number;

    // Cropping
    cropOffset?: { x: number; y: number };
    cropPadding?: { x: number; y: number };
  };

  scanFeedback?: {
    // Visual feedback during scanning
    style?:
      | 'rect'
      | 'contour_rect'
      | 'contour_point'
      | 'contour_underline';
    animation?:
      | 'none'
      | 'blink'
      | 'pulse'
      | 'kitt'
      | 'traverse_multi'
      | 'traverse_single'
      | 'resize'
      | 'resize_point'
      | 'resize_underline';
    animationDuration?: number;
    timeout?: number;               // Mobile SDK name: redrawTimeout

    // Styling
    strokeWidth?: number;
    strokeColor?: string;
    fillColor?: string;
    cornerRadius?: number;
  };
}

Cutout Position

alignment

Vertical alignment of the cutout within the viewport.

cutoutConfig: {
  alignment: 'center'  // Options: 'top', 'top_half', 'center', 'bottom_half', 'bottom'
}

Options:

  • 'top': Positioned at the top of the viewport

  • 'top_half' (default): Positioned in the upper half of the viewport

  • 'center': Centered vertically in the viewport

  • 'bottom_half': Positioned in the lower half of the viewport

  • 'bottom': Positioned at the bottom of the viewport

offset

Fine-tune cutout position with pixel offsets from the alignment point.

cutoutConfig: {
  alignment: 'center',
  offset: { x: 0, y: -50 }  // Move 50px up from center
}

Properties:

  • x: Horizontal offset in pixels (positive = right, negative = left)

  • y: Vertical offset in pixels (positive = down, negative = up)

A missing x or y counts as 0.

Cutout Size

width and height

Absolute dimensions in pixels.

cutoutConfig: {
  width: 1000,   // 1000px wide
  height: 600    // 600px tall
}

ratioFromSize

Define aspect ratio for responsive sizing.

cutoutConfig: {
  ratioFromSize: {
    width: 16,   // 16:9 aspect ratio
    height: 9
  }
}

Use ratioFromSize with maxWidthPercent and maxHeightPercent for responsive cutouts that adapt to different screen sizes.

maxWidthPercent and maxHeightPercent

Maximum dimensions as percentage of viewport. Use a whole number from 1 to 100, with or without % (e.g. '80%').

cutoutConfig: {
  ratioFromSize: { width: 16, height: 9 },
  maxWidthPercent: '80%',   // Max 80% of viewport width
  maxHeightPercent: '50%'   // Max 50% of viewport height
}

Responsive sizing strategy:

  1. width and height are capped by maxWidthPercent and maxHeightPercent

  2. If ratioFromSize is set, the longer dimension is reduced to preserve the ratio

// Example: Responsive barcode scanner
cutoutConfig: {
  alignment: 'center',
  ratioFromSize: { width: 16, height: 9 },
  width: 1000,              // Fallback absolute width
  maxWidthPercent: '90%',   // Max 90% of screen width
  maxHeightPercent: '60%'   // Max 60% of screen height
}

Cutout Visual Styling

strokeColor

Color of the cutout border. Accepts 6-digit RGB ('FFFFFF') or 8-digit ARGB ('FF00FF00' for opaque green) hex values. A leading # is allowed.

cutoutConfig: {
  strokeColor: '00FF00'  // Green border
}

inactiveStrokeColor

Border color when scanning is inactive or paused.

cutoutConfig: {
  strokeColor: '00FF00',          // Green when active
  inactiveStrokeColor: 'AAAAAA'   // Gray when inactive
}

strokeWidth

Border thickness in pixels.

cutoutConfig: {
  strokeWidth: 3  // Border thickness in pixels
}

cornerRadius

Border corner rounding in pixels.

cutoutConfig: {
  cornerRadius: 5  // Corner rounding in pixels (0 = sharp corners)
}

feedbackStrokeColor

Border color during successful scan feedback.

cutoutConfig: {
  strokeColor: 'FFFFFF',          // White normally
  feedbackStrokeColor: '00FF00'   // Green on success
}

delay

Delay (in seconds) before the cutout stroke animation starts when inactiveStrokeColor is set.

cutoutConfig: {
  delay: 0.5  // Delay in seconds
}

The cutout still renders immediately; this only delays the stroke animation that transitions from inactiveStrokeColor to strokeColor.

Cutout Cropping

Control which area around the cutout is scanned. Values are in camera frame pixels, as in the Mobile SDKs, so the same values work on every screen size. They are relative to the camera resolution: 50 pixels are a larger part of a 720p frame than of a 1080p frame.

cropOffset

Shift the scanned area relative to the cutout position.

cutoutConfig: {
  cropOffset: { x: 10, y: -5 }  // Shift the scanned area 10 camera pixels right, 5 up
}

cropPadding

Grow the scanned area on each side, as in the Mobile SDKs. Both values must be 0 or more.

cutoutConfig: {
  cropPadding: { x: 20, y: 20 }  // Scan 20 camera pixels more on all sides
}

cropOffset and cropPadding change the area that is scanned. They do not change the visual cutout outline. If the scanned area reaches outside the camera frame, it keeps its size and is moved back inside, as in the Mobile SDKs. An area larger than the frame is limited to the frame.

Scan Feedback Configuration

Real-time visual feedback during scanning, nested within each cutout. The Mobile SDK name scanFeedbackConfig is accepted too; use one of the two names, not both.

Basic Configuration

scanFeedback: {
  style: 'contour_point',          // Visual style
  animation: 'traverse_multi',     // Animation type (not used by 'rect' and 'contour_rect')
  animationDuration: 300,          // Animation speed (ms)
  timeout: 2000,                   // How long to display (ms)

  strokeWidth: 3,
  strokeColor: '00FF00',           // Feedback color
  fillColor: '3300FF00',           // 20% alpha (ARGB)
  cornerRadius: 5
}

style

Visual style of the scan feedback indicator. Defaults to 'contour_rect' when omitted, or to 'contour_point' when only an animation is set.

scanFeedback: {
  style: 'rect'
}

Options:

  • 'rect': One box around the detected object, such as the text, barcode or license plate. Use cases that do not report such a box, such as vin_with_user_guidance, show a box around each character instead

  • 'contour_rect': Box around each detected element (default)

  • 'contour_point': Single point indicator

  • 'contour_underline': Underline indicator

animation

Animation type for the scan feedback indicator - the visual element shown when content is detected within the cutout. For 'rect' and 'contour_rect' styles, animations are ignored.

This is different from feedbackAnimationStyle, which controls how the cutout border itself animates. See feedbackAnimationStyle for details.

scanFeedback: {
  animation: 'traverse_multi'
}

Options:

  • 'none': No animation

  • 'blink': Blink in/out

  • 'pulse': Pulse opacity

  • 'kitt': Back-and-forth sweep

  • 'traverse_multi': Multi-point sweep

  • 'traverse_single': Single-point sweep

  • 'resize': Resize effect (only for 'contour_point'/'contour_underline')

  • 'resize_point': Resize effect for points

  • 'resize_underline': Resize effect for underlines

The traverse_multi animation creates an animated line traversing the scan area during scanning.

animationDuration

Animation speed in milliseconds.

scanFeedback: {
  animation: 'traverse_multi',
  animationDuration: 250  // Fast animation
}

Lower values result in faster animations. Presets typically use 250 ms.

timeout

Duration to display feedback after successful scan (milliseconds). The Mobile SDK name redrawTimeout is accepted too; use one of the two names, not both.

scanFeedback: {
  timeout: 1500  // Show feedback for 1.5 seconds
}

strokeColor and fillColor accept 6-digit RGB or 8-digit ARGB hex values (AARRGGBB). A leading # is allowed.

Sensory Feedback

The beepOnResult, vibrateOnResult, and blinkAnimationOnResult properties that exist in our Mobile SDK ScanView configurations are accepted but not implemented in the Web SDK.

For limited sensory feedback on successful scans, use the root-level init parameters instead:

const anyline = init({
  hapticFeedback: true,   // Audio + haptic feedback on result
  flashOnResult: true,    // Visual screen blink on result (all platforms)
  // ... other config
});

See hapticFeedback and flashOnResult in the API Reference for details.

UI Feedback Configuration

UI feedback elements enhance the scanning experience by informing the user about environmental conditions detected during scanning. Incorporating visual cues (such as images or text) next to the cutout within the scan view can guide the user on how or what to scan.

For complete documentation on static instructions, dynamic feedback presets, and custom configurations, see UI Feedback.

See Also