function TipPluginBase::getLocation

Same name in other branches
  1. 10 core/modules/tour/src/TipPluginBase.php \Drupal\tour\TipPluginBase::getLocation()
  2. 11.x core/modules/tour/src/TipPluginBase.php \Drupal\tour\TipPluginBase::getLocation()

Determines the placement of the tip relative to the element.

If null, the tip will automatically determine the best position based on the element's position in the viewport.

Return value

string|null The tip placement relative to the element.

See also

https://shepherdjs.dev/docs/Step.html

File

core/modules/tour/src/TipPluginBase.php, line 157

Class

TipPluginBase
Defines a base tour item implementation.

Namespace

Drupal\tour

Code

public function getLocation() : ?string {
    $location = $this->get('position');
    // The location values accepted by PopperJS, the library used for
    // positioning the tip.
    assert(in_array(trim($location ?? ''), [
        'auto',
        'auto-start',
        'auto-end',
        'top',
        'top-start',
        'top-end',
        'bottom',
        'bottom-start',
        'bottom-end',
        'right',
        'right-start',
        'right-end',
        'left',
        'left-start',
        'left-end',
        '',
    ], TRUE), "{$location} is not a valid Tour Tip position value");
    return $location;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.