core/common/dropdown-fit-viewport.directive.ts

Description

Keeps the lower controls of an ngx-bootstrap dropdown menu, such as Apply, reachable on a short screen. Each time the menu opens, it is capped to the space next to its toggle and scrolls inside: below the toggle, or above it when the toggle is too close to the bottom of the screen and more room is above. An open menu closes when the viewport width changes, for example when a phone rotates, so it is never left with a fit for the previous screen. Focus inside the menu then goes back to the toggle.

Use it on menus that can be taller than the screen and that the page cannot scroll into view, for example a menu floating from the fixed action bar on a phone. It works with and without container="body".

The menu must be rendered with *dropdownMenu, so it exists only while open. A menu that opens upward stops below the fixed app header, which the directive measures from .app-main-header.

Example :
<div dropdown c8yDropdownFitViewport class="dropdown">
  <button class="dropdown-toggle" dropdownToggle>Custom range</button>
  <div class="dropdown-menu" *dropdownMenu>
    <!-- Date fields and Apply -->
  </div>
</div>

Example

<b>Example :</b><div><pre class="line-numbers"><code class="language-html">&lt;div dropdown c8yDropdownFitViewport class=&quot;dropdown&quot;&gt;
  &lt;button class=&quot;dropdown-toggle&quot; dropdownToggle&gt;Custom range&lt;/button&gt;
  &lt;div class=&quot;dropdown-menu&quot; *dropdownMenu&gt;
    &lt;!-- Date fields and Apply --&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre></div>

Metadata

Relationships

results matching ""

    No results matching ""