scrollClasses

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.feature

This feature allows you to have -scrolled, -scrolled-x, -scrolled-y, -scrolled-up and -scrolled-down classes added and removed from the body depending on an scroll offset that can be set by:

  1. -scrolled: Added when passed the offset set in the settings
  2. -scrolled-x: Added when passed the offsetX set in the settings
  3. -scrolled-y: Added when passed the offsetY set in the settings
  4. -scrolled-up: Added when the user scrolls up (no offset)
  5. -scrolled-down: Added when the user scrolls down (no offset)

Note that you can specify these settings in the CSS with the following variables:

  • --s-scrolled-classes-offset: The offset you want before adding the classes
  • --s-scrolled-classes-offset-x: The offset x you want before adding the classes
  • --s-scrolled-classes-offset-y: The offset y you want before adding the classes
  • --s-scrolled-classes-class: The class name you want. Will be used also in the %cls-x and %cls-y classes

Params

  1. settings{}TScrollClassesSettings

    The settings you want to override

Example

import { scrollClasses } from '@blackbyte/sugar/features';
scrollClasses({
     class: 'hello',
     offset: 200
});

Settings

  1. offset100number

    The offset you want before adding the classes

  2. offsetX-number

    The offset x you want before adding the classes

  3. offsetY-number

    The offset y you want before adding the classes

  4. classscrolledstring

    The class name you want. Will be used also in the %cls-x and %cls-y classes