swissup/module-stickybits

Stickybits is a lightweight alternative to `position: sticky` polyfills

Installs: 210

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 5

Forks: 2

Open Issues: 0

Language:JavaScript

Type:magento2-module

1.0.1 2020-03-12 09:05 UTC

This package is auto-updated.

Last update: 2024-04-12 18:07:34 UTC


README

This repo is just an integration of original library into Magento 2.

Stickybits is a lightweight alternative to position: sticky polyfills. It works perfectly for things like sticky headers.

See original repository for more information: https://github.com/dollarshaveclub/stickybits

Installation

cd <magento_root>
composer require swissup/module-stickybits
bin/magento module:enable Swissup_Stickybits
bin/magento setup:upgrade

Usage

Basic example:

require(['stickybits'], function (stickybits) {
    stickybits('.sidebar');
});

See all examples at official site: https://github.com/dollarshaveclub/stickybits#basic-usage

Advanced example (works for dynamically added elements):

require([
    'Magento_Ui/js/lib/view/utils/async',
    'stickybits'
], function ($, stickybits) {
    $.async('.sidebar', function (el) {
        stickybits(el, {
            useStickyClasses: true,
            stuckClass: 'is_stuck'
        });
    });
});