定制 swissup/module-stickyfill 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

swissup/module-stickyfill

最新稳定版本:1.2.2

Composer 安装命令:

composer require swissup/module-stickyfill

包简介

The most accurate sticky polyfill out in the wild for Magento 2

README 文档

README

Stickyfill - is a Magento2 module that integrates Stickyfill library into Magento.

The module also provides additional features: it may add sticky-active class, when element is actually stuck at the moment.

Installation

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

Usage

Basic example:

require(['stickyfill'], function (Stickyfill) {
    Stickyfill.add(document.querySelectorAll('.sidebar'));
});

See all available methods at official site: https://github.com/wilddeer/stickyfill#api

Advanced example (works for dynamically added elements):

require([
    'Magento_Ui/js/lib/view/utils/async',
    'stickyfill'
], function ($, Stickyfill) {
    $.async('.sidebar', function (el) {
        Stickyfill.add(el);
    });
});

Additional features

Swissup_Stickyfill/js/sticky - is a proxy to stickyfill library that adds sticky-active class name when element is stuck. It has the following methods:

Method Description
add Proxy to Stickyfill.add
remove Proxy to Stickyfill.remove
stickyfill Returns Stickyfill object

Basic usage:

require([
    'Swissup_Stickyfill/js/sticky'
], function (sticky) {
    sticky.add(document.querySelectorAll('.sidebar'))
});

Using with matchMedia library:

require([
    'matchMedia',
    'Swissup_Stickyfill/js/sticky'
], function (mediaCheck, sticky) {
    'use strict';

    var sidebar = document.querySelectorAll('.sidebar');

    mediaCheck({
        media: '(min-width: 768px)',
        entry: function () {
            sticky.add(sidebar);
        },
        exit: function () {
            sticky.remove(sidebar);
        }
    });
});

统计信息

  • 总下载量: 299.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 7
  • Forks: 3
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-26