class ParallaxBgModifier in Modifiers Pack 8
Provides a Modifier to set the parallax background on an element.
Plugin annotation
@Modifier(
id = "parallax_bg_modifier",
label = @Translation("Parallax Background Modifier"),
description = @Translation("Provides a Modifier to set the parallax background on an element."),
)
Hierarchy
- class \Drupal\modifiers_bg_parallax\Plugin\modifiers\ParallaxBgModifier extends \Drupal\modifiers\ModifierPluginBase
Expanded class hierarchy of ParallaxBgModifier
1 file declares its use of ParallaxBgModifier
- ParallaxBgModifierTest.php in modules/
modifiers_bg_parallax/ tests/ src/ Unit/ ParallaxBgModifierTest.php
2 string references to 'ParallaxBgModifier'
- ParallaxBgModifier::modification in modules/
modifiers_bg_parallax/ src/ Plugin/ modifiers/ ParallaxBgModifier.php - ParallaxBgModifierTest::testModification in modules/
modifiers_bg_parallax/ tests/ src/ Unit/ ParallaxBgModifierTest.php - @covers ::modification
File
- modules/
modifiers_bg_parallax/ src/ Plugin/ modifiers/ ParallaxBgModifier.php, line 17
Namespace
Drupal\modifiers_bg_parallax\Plugin\modifiersView source
class ParallaxBgModifier extends ModifierPluginBase {
/**
* {@inheritdoc}
*/
public static function modification($selector, array $config) {
if (!empty($config['parallax'])) {
$media = parent::getMediaQuery($config);
$args['image'] = $config['parallax'];
if (!empty($config['parallax_speed'])) {
$args['speed'] = (double) $config['parallax_speed'];
}
if (!empty($config['bgp_color_val'])) {
$args['color'] = $config['bgp_color_val'];
}
$libraries = [
'modifiers_bg_parallax/apply',
];
$settings = [
'namespace' => 'ParallaxBgModifier',
'callback' => 'apply',
'selector' => $selector,
'media' => $media,
'args' => $args,
];
$attributes[$media][$selector]['class'][] = 'modifiers-has-background';
return new Modification([], $libraries, $settings, $attributes);
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ParallaxBgModifier:: |
public static | function |