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
- Install minimal profile
- Place a the system branding block with a data-offset-top attribute and core/displace
- 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
- Write a merge request
- Review
- 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
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
Comment #3
idebr commentedIssue needs tests to confirm the CSS variables are available on page load