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
ViewConfig Structure
interface ViewConfig {
// Global overlay styling
outerColor?: string; // 6-digit hex RGB without # (e.g., '000000')
outerAlpha?: number; // Overlay opacity 0-1
// Cutout stroke animation style
feedbackAnimationStyle?: 'blink' | 'path'; // Default: 'blink'
// Legacy/global feedback fields (see notes below)
feedbackStyle?: string;
animation?: string;
// 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, without '#' prefix). Transparency is controlled by outerAlpha.
viewConfig: {
outerColor: '000000' // Black overlay
}
Common choices include 'FFFFFF' for a light overlay or '1A1A1A' for a dark gray shade. Remember to omit the # prefix.
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.
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. If defined, the cutouts array must contain at least one cutout configuration. Otherwise, we provide default cutout configurations for each preset.
ICutout Structure
interface ICutout {
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
style?: 'rect' | 'contour_rect';
strokeColor?: string;
inactiveStrokeColor?: string;
strokeWidth?: number;
cornerRadius?: number;
feedbackStrokeColor?: string;
// Animation
animation?: string;
delay?: number;
// Reserved (not applied to the overlay in the Web SDK)
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;
// 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)
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.
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
style
Cutout border style.
cutoutConfig: {
style: 'rect' // or 'contour_rect'
}
Options:
-
'rect': Standard rectangular border -
'contour_rect': Rounded/contoured rectangular border
strokeColor
Color of the cutout border. Accepts 6-digit RGB ('FFFFFF') or 8-digit ARGB ('FF00FF00' for opaque green) hex values without # prefix.
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 how the captured image is cropped relative to the cutout.
cropOffset
Shift the crop area relative to the cutout position.
cutoutConfig: {
cropOffset: { x: 10, y: -5 } // Shift crop area 10px right, 5px up
}
cropPadding
Add padding around the cutout when cropping the result image.
cutoutConfig: {
cropPadding: { x: 20, y: 20 } // Add 20px padding on all sides
}
|
|
Scan Feedback Configuration
Real-time visual feedback during scanning, nested within each cutout.
Basic Configuration
scanFeedback: {
style: 'rect', // Visual style
animation: 'traverse_multi', // Animation type
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_point' when omitted.
scanFeedback: {
style: 'rect'
}
Options:
-
'rect': Standard rectangular feedback -
'contour_rect': Rounded contour feedback -
'contour_point': Single point indicator (default) -
'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).
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