简体   繁体   English

将悬浮状态添加到Bigcommerce模具主题

[英]Add hoverintent to Bigcommerce Stencil theme

I am tryig to use hoverintent with a bigcommerce stencil theme and I cannot get ti to work. 我是tryig,将hoverintent与bigcommerce模板主题一起使用,因此无法正常工作。

  1. Install the plugin 安装插件
    $npm install hoverintent $ npm安装hoverintent

  2. hoverintent.js hoverintent.js
    /assets/js/theme/global/hoverintent.js /assets/js/theme/global/hoverintent.js


import request from 'hoverintent';

export default function () {
    $(function() {
        $('.navigation-main li').hoverIntent(hoverOver , hoverOut);
    });

    // expand the height of the container 
    function hoverOver(){
        $(this).addClass('js-hover');
    }

    // reset the height of the container 
    function hoverOut() {
        $(this).removeClass('js-hover');
    }
}

  1. Update global.js 更新global.js
    /assets/js/theme/global.js /assets/js/theme/global.js

import $ from 'jquery';

...

import hoverIntent from './global/hoverintent';

...

export default class Global extends PageManager {

    loaded(next) {
        ...
        hoverIntent();
        next();
    }
}

This is the error that I get in the browser. 这是我在浏览器中遇到的错误。

TypeError: $('.navigation-main li').hoverIntent is not a function. TypeError:$('。navigation-main li')。hoverIntent不是函数。 (In '$('.navigation-main li').hoverIntent(hoverOver, hoverOut)', '$('.navigation-main li').hoverIntent' is undefined) (在'$('。navigation-main li')。hoverIntent(hoverOver,hoverOut)'中,'$('。navigation-main li')。hoverIntent'未定义)

I could not figure out how to get hover intent to work on bigcommerce stencil theme so I went with a pure css way. 我无法弄清楚如何在大电子商务模具主题上进行悬停工作,所以我采用了纯CSS方法。 There are a few good tutorials online about this topic. 在线上有一些很好的关于此主题的教程。 Here is the on I referenced, by J. Hogue. 这是我参考的J. Hogue。

http://codepen.io/jhogue/pen/payuj http://codepen.io/jhogue/pen/payuj

.submenu {position: absolute; top: 100%;}
.element .submenu {transition: all 0s ease; left: -999em;}
.element:hover .submenu{ transition-delay: .25s; left: 0;}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM