Specialized effects designed for background media elements and hero sections. Perfect for creating immersive backgrounds, parallax landscapes, and cinematic scroll experiences.
Background scroll animations are scrub-based animations specifically optimized for background media elements. They target elements with data-motion-part attributes and automatically measure container dimensions for accurate calculations. These animations create immersive, large-scale visual effects.
- Purpose: Hero sections, background media, immersive experiences
- Trigger: Scroll position with viewport intersection
- Target: Background media layers (
BG_LAYER,BG_MEDIA,BG_IMG) - Measurement: Auto-calculated component dimensions
- Scale: Designed for large viewport interactions
Classic parallax scrolling and directional movement effects.
Dynamic scaling and perspective zoom effects.
Sophisticated opacity transitions and layered fading.
Rotational effects and complex transformations.
Complex perspective effects with multi-layer interactions.
| Animation | Category | Complexity | Direction Support | Measurement | Description |
|---|---|---|---|---|---|
| BgParallax | Parallax | Simple | - | ✓ | Classic background parallax movement |
| ImageParallax | Parallax | Medium | - | ✓ | Enhanced image parallax with options |
| BgPan | Movement | Simple | 2-way | ✓ | Horizontal panning movement |
| BgZoom | Zoom | Complex | 2-way | ✓ | Dynamic zoom in/out effects |
| BgCloseUp | Zoom | Medium | - | ✓ | Perspective zoom with fade |
| BgPullBack | Zoom | Medium | - | ✓ | 3D pull-back effect |
| BgFade | Fade | Simple | - | ✓ | Directional fade transitions |
| BgFadeBack | Fade | Medium | - | ✓ | Scale + fade combination |
| BgRotate | Transform | Simple | 2-way | - | Smooth rotation effects |
| BgSkew | Transform | Medium | 2-way | ✓ | Skewing transformation |
| BgFake3D | 3D | Complex | - | ✓ | Multi-layer 3D parallax |
| BgReveal | Special | Simple | - | ✓ | Measurement-only reveal |
Background scroll animations target specific element parts:
<!-- container -->
<section id="hero-section">
<!-- Background layer container -->
<div data-motion-part="BG_LAYER">
<!-- Background media layer -->
<div data-motion-part="BG_MEDIA">
<img src="background.jpg" data-motion-part="BG_IMG" />
</div>
</div>
</section>BG_LAYER- Background container layerBG_MEDIA- Main background media containerBG_IMG- Background image element
const bgScene = getWebAnimation(
'#hero-background',
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'BgParallax',
speed: 0.3, // 30% of scroll speed
},
},
{
trigger: 'view-progress',
element: document.body,
},
);{
type: 'BgParallax',
speed: 0.2 // 0.1 = slow, 0.5 = medium, 1.0 = fast
}
{
type: 'BgPan',
speed: 0.4 // Panning speed multiplier
}// Two-way directions
{ type: 'BgPan', direction: 'left' | 'right' }
{ type: 'BgRotate', direction: 'clockwise' | 'counter-clockwise' }
{ type: 'BgSkew', direction: 'clockwise' | 'counter-clockwise' }
// Zoom directions
{ type: 'BgZoom', direction: 'in' | 'out' }{
type: 'BgZoom',
zoom: 40, // Zoom amount
direction: 'in' // Zoom direction
}
{
type: 'BgCloseUp',
scale: 80 // Perspective scale value
}
{
type: 'BgSkew',
angle: 20 // Skew angle in degrees
}Best for: Hero backgrounds, landscape imagery, layered compositions
{
type: 'BgParallax',
speed: 0.3 // Background moves at 30% of scroll speed
}
// Classic parallax: background moves slower than scrollBest for: Enhanced parallax with additional control options
{
type: 'ImageParallax',
speed: 1.5, // Parallax speed multiplier
reverse: false, // Reverse movement direction
isPage: false // Page-level vs component-level
}
// Enhanced parallax with directional and scope controlBest for: Wide backgrounds, horizontal movement, cinematic panning
{
type: 'BgPan',
direction: 'left', // 'left' | 'right'
speed: 0.2 // Panning speed
}
// Horizontal panning movement across viewportBest for: Hero sections, dramatic reveals, immersive experiences
{
type: 'BgZoom',
direction: 'in', // 'in' | 'out'
zoom: 40 // Zoom intensity
}
// Dynamic zoom with perspective and Y-axis movementBest for: Perspective reveals, depth effects, layered backgrounds
{
type: 'BgCloseUp',
scale: 80 // Perspective scale amount
}
// Combines perspective zoom with fade on background layerBest for: 3D reveal effects, depth transitions
{
type: 'BgPullBack',
scale: 50 // Pull-back distance
}
// 3D pull-back effect with perspective transformationBest for: Simple background transitions, overlay effects
{
type: 'BgFade',
range: 'in' // 'in' | 'out'
}
// Directional fade transitions on background layerBest for: Scale + fade combinations, gentle transitions
{
type: 'BgFadeBack',
scale: 0.7 // Scale amount during fade
}
// Combines scaling and opacity changesBest for: Rotating backgrounds, dynamic orientations
{
type: 'BgRotate',
direction: 'counter-clockwise', // Rotation direction
angle: 22 // Rotation angle
}
// Smooth rotation effect on background mediaBest for: Dynamic layouts, creative distortions
{
type: 'BgSkew',
direction: 'counter-clockwise', // Skew direction
angle: 20 // Skew angle
}
// Skewing transformation with oscillating motionBest for: Complex 3D effects, multi-layer parallax, showcase backgrounds
{
type: 'BgFake3D',
stretch: 1.3, // Y-axis stretch amount
zoom: 16.67 // 3D zoom distance
}
// Multi-layer 3D effect with stretch, zoom, and Y-movementBest for: Measurement-based reveals, container preparations
{
type: 'BgReveal';
// No visual effect - performs measurements for other animations
}
// Utility animation for measurement and preparation// Layer 1: Background parallax
getWebAnimation(
'#bg-layer-1',
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'BgParallax',
speed: 0.2,
},
},
triggerConfig,
);
// Layer 2: Faster parallax
getWebAnimation(
'#bg-layer-2',
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'BgParallax',
speed: 0.5,
},
},
triggerConfig,
);
// Layer 3: Zoom effect
getWebAnimation(
'#bg-layer-3',
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'BgZoom',
direction: 'in',
zoom: 30,
},
},
triggerConfig,
);{
type: 'BgFade',
range: 'in',
startOffset: {
name: 'cover',
offset: { value: 0, type: 'percentage' }
},
endOffset: {
name: 'cover',
offset: { value: 50, type: 'percentage' }
}
}// Auto-measurement for responsive effects
{
type: 'BgFake3D',
stretch: 1.3,
zoom: 100 / 6 // Calculated based on component size
}
// Animation automatically measures component height// Best performance: Transform-only animations
const efficientAnimations = [
'BgParallax', // translateY only
'BgPan', // translateX only
'BgRotate', // rotate only
'BgZoom', // perspective + translateZ
];
// Moderate performance: Multi-property animations
const moderateAnimations = [
'BgFake3D', // Multiple transform layers
'BgCloseUp', // Perspective + opacity
'BgSkew', // Skew + position
];// Batch measurements for multiple background animations
import { prepareAnimation } from '@wix/motion';
elements.forEach((element) => {
prepareAnimation(element, backgroundAnimationConfig);
});
// Then create animations after measurements complete
elements.forEach((element) => {
getWebAnimation(element, backgroundAnimationConfig, trigger);
});<section id="hero">
<div class="hero-background">
<div data-motion-part="BG_MEDIA">
<img src="hero-bg.jpg" data-motion-part="BG_IMG" />
</div>
<div data-motion-part="BG_LAYER" class="hero-overlay"></div>
</div>
<div class="hero-content">
<h1>Hero Title</h1>
</div>
</section>// Background parallax
getWebAnimation(
'.hero-background',
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'BgParallax',
speed: 0.3,
},
},
{
trigger: 'view-progress',
element: document.body,
},
);
// Overlay fade
getWebAnimation(
'.hero-background',
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'BgFade',
range: 'out',
},
},
{
trigger: 'view-progress',
element: document.querySelector('#hero'),
},
);const fullPageBg = getWebAnimation(
'#page-background',
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'ImageParallax',
speed: 1.2,
isPage: true, // Full page scope
},
},
{
trigger: 'view-progress',
element: document.body,
},
);document.querySelectorAll('.gallery-item').forEach((item) => {
getWebAnimation(
item,
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'BgZoom',
direction: 'in',
zoom: 25,
},
},
{
trigger: 'view-progress',
element: item,
},
);
});const scene3D = getWebAnimation(
'#showcase-bg',
{
type: 'ScrubAnimationOptions',
namedEffect: {
type: 'BgFake3D',
stretch: 1.4,
zoom: 20,
},
},
{
trigger: 'view-progress',
element: document.body,
},
);const isMobile = window.innerWidth < 768;
const bgConfig = {
type: 'ScrubAnimationOptions',
namedEffect: isMobile
? { type: 'BgFade', range: 'in' } // Simple fade on mobile
: { type: 'BgFake3D', stretch: 1.3 }, // Complex 3D on desktop
};const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (prefersReducedMotion) {
// Use simple, non-moving backgrounds
const config = { type: 'BgReveal' };
} else {
// Full background animation experience
const config = { type: 'BgParallax', speed: 0.3 };
}// Scale effects based on viewport size
const viewportMultiplier = Math.min(window.innerWidth / 1920, 1);
{
type: 'BgZoom',
zoom: 40 * viewportMultiplier, // Scale zoom for smaller screens
direction: 'in'
}.hero-background {
position: relative;
height: 100vh;
overflow: hidden;
}
[data-motion-part='BG_MEDIA'] {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
will-change: transform;
}
[data-motion-part='BG_IMG'] {
width: 100%;
height: 100%;
object-fit: cover;
}
[data-motion-part='BG_LAYER'] {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom, transparent, rgb(0 0 0 / 0.5));
}/* Motion generates CSS custom properties */
[data-motion-part='BG_MEDIA'] {
transform: translateY(var(--motion-translate-y, 0));
}
/* Component height is automatically measured */
.hero-section {
--motion-comp-height: 100vh; /* Set by animation */
}Complete: You've explored all animation categories! Return to the Category Overview or check out Performance Optimization for advanced usage patterns.