function LayoutBuilderDisableInteractionsTest::getElementVerticalPosition

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::getElementVerticalPosition()
  2. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::getElementVerticalPosition()
  3. 10 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::getElementVerticalPosition()

Gets the element position.

Parameters

string $css_selector: The CSS selector of the element.

string $position_type: The position type to get, either 'top' or 'bottom'.

Return value

int The element position.

1 call to LayoutBuilderDisableInteractionsTest::getElementVerticalPosition()
LayoutBuilderDisableInteractionsTest::assertContextualLinkRetainsMouseup in core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
Makes sure contextual links respond to mouseup event.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php, line 318

Class

LayoutBuilderDisableInteractionsTest
Tests the Layout Builder disables interactions of rendered blocks.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function getElementVerticalPosition($css_selector, $position_type) : int {
    $this->assertContains($position_type, [
        'top',
        'bottom',
    ], 'Expected position type.');
    return (int) $this->getSession()
        ->evaluateScript("document.querySelector('{$css_selector}').getBoundingClientRect().{$position_type} + window.pageYOffset");
}

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