novicell / premium_tools
Premium Tools
Installs: 0
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:drupal-module
README
The module has no special installation steps. This document will explain what features it provides and how you can use them.
What are the features of this module?
- Each developer who adds code to this module is responsible for adding a feature description in this file, or providing an example in an example file in the module.
Ajax Commands
The 'ScrollTo' Ajax Command
- Purpose:
With this command you can make an ajax form scroll on an action. This is useful when removing/showing new content in an Ajax form.
- Usage:
- Add the library to your form, like so
$form['#attached']['library'][] = 'dds_tools/scroll_to_command';
- Use the command in your Ajax callback function, like so:
$response = new JsonResponse(); $response->addCommand(new ScrollToCommand([ 'selector' => '#selector', 'header_selectors' => ['.js-header', '.js-main-navigation'], 'offsetOrPosition' => 'offset', ])); return $response;
The parameters for the command are as follows: The parameters for the command are as follows:
- selector: string
- The selector to scroll to.
- header_selector: array
- If the site has a fixed header, give the header class(es) to offset it.
- offsetOrPosition: string
- If the scroll should be relative to the document or to the selector.
- 'offset' is relative to the document
- '' will default to using jQuery position, relative to the selector.
- If the scroll should be relative to the document or to the selector.