Parallax
in package
implements
BehaviorInterface
Parallax behavior for scroll-based parallax effects.
The parallax behavior makes a component move at a different rate than the scroll speed, creating a depth effect. The factor determines how much slower (< 1) or faster (> 1) the component moves relative to scroll.
Tags
Table of Contents
Interfaces
- BehaviorInterface
- Interface for all ANF component behaviors.
Properties
- $factor : float
Methods
- __construct() : mixed
- Create a new Parallax behavior.
- getFactor() : float
- Get the parallax factor.
- getType() : string
- Get the behavior type identifier.
- jsonSerialize() : array{type: string, factor: float}
- {@inheritdoc}
- moderate() : self
- Create a moderate parallax effect.
- strong() : self
- Create a strong parallax effect.
- subtle() : self
- Create a subtle parallax effect.
- withFactor() : self
- Create a Parallax with a specific factor.
Properties
$factor read-only
private
float
$factor
= 0.9
Methods
__construct()
Create a new Parallax behavior.
public
__construct([float $factor = 0.9 ]) : mixed
Parameters
- $factor : float = 0.9
-
The parallax factor. Values less than 1.0 make the component scroll slower than the content (appearing further away). Typical values range from 0.5 to 0.9.
getFactor()
Get the parallax factor.
public
getFactor() : float
Return values
float —The factor value.
getType()
Get the behavior type identifier.
public
getType() : string
Return values
string —The behavior type (e.g., 'parallax', 'springy').
jsonSerialize()
{@inheritdoc}
public
jsonSerialize() : array{type: string, factor: float}
Return values
array{type: string, factor: float}moderate()
Create a moderate parallax effect.
public
static moderate() : self
Return values
self —A Parallax with factor 0.7.
strong()
Create a strong parallax effect.
public
static strong() : self
Return values
self —A Parallax with factor 0.5.
subtle()
Create a subtle parallax effect.
public
static subtle() : self
Return values
self —A Parallax with factor 0.9.
withFactor()
Create a Parallax with a specific factor.
public
static withFactor(float $factor) : self
Parameters
- $factor : float
-
The parallax factor (0.0 to 2.0 typical range).
Return values
self —A new Parallax instance.