class ScrollToElementCommand in Paragraphs Features 8
Same name and namespace in other branches
- 2.x src/Ajax/ScrollToElementCommand.php \Drupal\paragraphs_features\Ajax\ScrollToElementCommand
Provides an AJAX command for scrolling an element into the view.
This command is implemented in Drupal.AjaxCommands.prototype.scrollToElement.
Hierarchy
- class \Drupal\paragraphs_features\Ajax\ScrollToElementCommand implements CommandInterface
Expanded class hierarchy of ScrollToElementCommand
1 file declares its use of ScrollToElementCommand
File
- src/
Ajax/ ScrollToElementCommand.php, line 12
Namespace
Drupal\paragraphs_features\AjaxView source
class ScrollToElementCommand implements CommandInterface {
/**
* A CSS selector string.
*
* @var string
*/
protected $elementSelector;
/**
* A CSS selector string.
*
* @var string
*/
protected $parentSelector;
/**
* Constructs a ScrollToElementCommand object.
*
* @param string $elementSelector
* The data-drupal-selector for the paragraphs element.
* @param string $parentSelector
* The data-drupal-selector for the paragraphs field.
*/
public function __construct(string $elementSelector, string $parentSelector) {
$this->elementSelector = $elementSelector;
$this->parentSelector = $parentSelector;
}
/**
* {@inheritdoc}
*/
public function render() {
return [
'command' => 'scrollToElement',
'drupalElementSelector' => $this->elementSelector,
'drupalParentSelector' => $this->parentSelector,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ScrollToElementCommand:: |
protected | property | A CSS selector string. | |
ScrollToElementCommand:: |
protected | property | A CSS selector string. | |
ScrollToElementCommand:: |
public | function |
Return an array to be run through json_encode and sent to the client. Overrides CommandInterface:: |
|
ScrollToElementCommand:: |
public | function | Constructs a ScrollToElementCommand object. |