Parallax Types
Jarallax supports multiple parallax effect types through thetype option.
scroll (Default)
Standard parallax scrolling effect where the background moves at a different speed than the content.This is the most common parallax effect. The background scrolls slower than the page scroll.
scale
Scales (zooms) the image based on scroll position instead of translating it.- Positive Speed
- Negative Speed
opacity
Fades the image in and out based on its visibility in the viewport.The
speed option affects how the opacity changes. The image opacity is calculated based on how much of the element is visible in the viewport.scroll-opacity
Combines the scroll effect with opacity changes.scale-opacity
Combines the scale effect with opacity changes.Type Comparison
Speed Configuration
Thespeed option controls the intensity of the parallax effect. It accepts values from -1.0 to 2.0.
Understanding Speed Values
Understanding Speed Values
0: Background is completely fixed (no movement)0.5(default): Standard parallax effect1.0: Background moves at the same speed as scrolling (no parallax)-1.0to0: Reverse parallax (background moves opposite direction)0to1.0: Slower than scroll (classic parallax)1.0to2.0: Faster than scroll
Speed Examples
Speed Examples
- Slow Parallax
- Fast Parallax
- Fixed Background
- Reverse Parallax
Mobile Device Detection
Jarallax provides flexible options for disabling parallax on mobile devices to improve performance.Using Regular Expressions
Using Functions
Custom Detection Logic
Disable Video on Mobile
Separately control video background loading on mobile:Performance Optimization
Image Position
Jarallax automatically determines the best CSS position value (fixed or absolute) for optimal performance:
Jarallax uses
position: fixed by default for optimal performance on most browsers, including MacOS with smooth scrolling. It automatically switches to absolute if parent elements have transforms or scroll overflow.When Position is Absolute
Foropacity, scale, scale-opacity types, or when speed is 1, position is automatically set to absolute:
Custom Viewport Element
Optimize performance by checking visibility against a custom element instead of the window:This is useful when your parallax elements are inside a scrollable container rather than the main window. See Issue #13 for details.
Video Performance Options
1
Enable Lazy Loading
Only load videos when they enter the viewport:
2
Play Only When Visible
Pause videos when they leave the viewport:
3
Disable on Mobile
Skip video loading on mobile devices:
Container Styling
Customize the parallax container appearance:Custom Container Class
The default container class is
jarallax-container.Z-Index Control
Image Options
Keep Original Image
Prevent Jarallax from moving the original image element:When
true, Jarallax clones the image instead of moving it. This is useful when you need to maintain the original image in the DOM for other purposes.Image Source
Explicitly set the image source:Image Element Selector
Customize the selector for finding the image element:'.jarallax-img'
Complete Advanced Example
Here’s a complete example using advanced options:Best Practices
Mobile Performance
Use
disableParallax and disableVideo on mobile devices to improve performance and reduce data usage.Speed Selection
Keep speed between
0.2 and 0.8 for subtle, professional effects. Higher values can be disorienting.Video Optimization
Always enable
videoLazyLoading and videoPlayOnlyVisible for pages with multiple video backgrounds.Type Selection
Use
scroll for most cases, scale for dramatic reveals, and opacity for subtle fades.Next Steps
Events & Methods
Learn how to control Jarallax instances programmatically
Basic Usage
Review the fundamentals of Jarallax
