class WebformScrollTopCommand in Webform 8.5
Same name and namespace in other branches
- 6.x src/Ajax/WebformScrollTopCommand.php \Drupal\webform\Ajax\WebformScrollTopCommand
Provides an Ajax command for scrolling to the top of an element.
This command is implemented in Drupal.AjaxCommands.prototype.webformScrollTop.
Hierarchy
- class \Drupal\webform\Ajax\WebformScrollTopCommand implements CommandInterface
Expanded class hierarchy of WebformScrollTopCommand
1 file declares its use of WebformScrollTopCommand
- WebformAjaxFormTrait.php in src/
Form/ WebformAjaxFormTrait.php
File
- src/
Ajax/ WebformScrollTopCommand.php, line 12
Namespace
Drupal\webform\AjaxView source
class WebformScrollTopCommand implements CommandInterface {
/**
* A CSS selector string.
*
* @var string
*/
protected $selector;
/**
* Scroll to target.
*
* @var string
*/
protected $target;
/**
* Constructs a \Drupal\webform\Ajax\ScrollTopCommand object.
*
* @param string $selector
* A CSS selector.
* @param string $target
* Scroll to target which can be 'form' or 'page'. Defaults to 'form'.
*/
public function __construct($selector, $target = 'form') {
$this->selector = $selector;
$this->target = $target;
}
/**
* {@inheritdoc}
*/
public function render() {
return [
'command' => 'webformScrollTop',
'selector' => $this->selector,
'target' => $this->target,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebformScrollTopCommand:: |
protected | property | A CSS selector string. | |
WebformScrollTopCommand:: |
protected | property | Scroll to target. | |
WebformScrollTopCommand:: |
public | function |
Return an array to be run through json_encode and sent to the client. Overrides CommandInterface:: |
|
WebformScrollTopCommand:: |
public | function | Constructs a \Drupal\webform\Ajax\ScrollTopCommand object. |