ScrollPos-Styler

This project is not covered by Drupal’s security advisory policy.

Adds CSS class to a HTML element depending on scroll position.

This module adds a format filter:

  • Enable ScrollPos-Styler adding (class="sps") to your elements.
  • Configure the scroll position in px to trigger the style adding (data-sps-offset="80") to your elements.
  • "sps--abv" or "sps--blw" classes will be added when the window is scrolled above/below the defined position.

Form element example:

$form['container'] = [
  '#type' => 'container',
  '#attributes' => [
    'class' => ['sps'],
    'data-sps-offset' => '80',
    '#attached' => [
      'library' => [
        'scrollpos_styler/library',
      ],
    ],
  ],
];

Sponsors

Supporting organizations: 

Project information

Releases