mediarox/module-js-hc-offcanvas-nav

HC Off-canvas Nav 的 Magento 2 模块

0.0.6 2022-03-16 08:39 UTC

This package is auto-updated.

Last update: 2024-09-16 13:47:23 UTC


README

此仓库只是将原始的包括 CSS 的 js-library 整合到 Magento 2 中。

用于创建使用 ARIA 的离屏多级导航的 JavaScript 库,无需依赖,同时也可作为 jQuery 插件使用。

更多信息请查看原始仓库:https://github.com/somewebmedia/hc-offcanvas-nav

安装

cd <magento_root>
composer require mediarox/module-js-hc-offcanvas-nav
bin/magento setup:upgrade

使用示例

?>
<script>
    require([
        'jquery',
        'hcOffcanvasNav'
    ], function ($, hcOffcanvasNav) {
        // create global instance. info: the call as jQuery plugin ($(selector).hcOffcanvasNav) does not work reliably.
        window.topMenuNavigation = new hcOffcanvasNav('nav.navigation', {
            disableAt: 768,
            labelBack: '<?= $escaper->escapeHtml(__('Back')) ?>',
            width: '100%',
            levelTitles: true,
            levelTitleAsBack: true
        });
        // handle magento mobile nav trigger click. (the "customToggle" option causes collisions in the design.)   
        $('[data-action="toggle-nav"]').on('click', function(event) {
            event.preventDefault();
            window.topMenuNavigation.open();
        });
    });
</script>