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, |
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 |
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 |
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:
-
widthandheightare capped bymaxWidthPercentandmaxHeightPercent -
If
ratioFromSizeis 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)
}
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
}
|
|
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 asvin_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 |
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
}
|
|
Sensory Feedback
|
The For limited sensory feedback on successful scans, use the root-level init parameters instead:
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
-
Plugin Configuration - Plugin configuration and presets
-
API Reference - Complete API documentation
-
UI Feedback - Dynamic user guidance configuration
-
Error Handling - Error handling guide
-
Getting Started - Getting started guide