Problem/Motivation

When creating themes for Drupal, themers frequently want to place fixed items against the edge of the viewport. This will cause the fixed element to overlap the toolbar (or other admin element). Drupal uses displace.js to place CSS variables on the html element to allow specifying the offset.

However, displace.js currently triggers on the window resize event. As a result, the offsets are not available on the initial page load and it cannot be used for its intended purpose for on-page elements.

Steps to reproduce

  1. Install minimal profile
  2. Place a the system branding block with a data-offset-top attribute and core/displace
  3. Notice the css variable is not available until the viewport is resized

Proposed resolution

Trigger displace.js on initial page load to enable integration with on-page elements

Remaining tasks

  1. Write a merge request
  2. Review
  3. Commit

User interface changes

None

Introduced terminology

None

API changes

displace.js is triggered on initial page load to enable integration with on-page elements

Data model changes

None

Release notes snippet

displace.js is triggered on initial page load to enable integration with on-page elements

Issue fork drupal-3610836

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs work

Issue needs tests to confirm the CSS variables are available on page load