简体   繁体   English

使用滤镜后,流沙投资组合的悬停效果仍然可见

[英]quicksand portfolio hover effect stays visible after using filter

I read a lot about people having trouble with quicksand and hover effects because they wouldn't be visible after filtering. 我读了很多关于人们在使用流沙和悬停效果时遇到麻烦的信息,因为它们在过滤后将不可见。

In my case it's the exact opposite. 就我而言,情况恰恰相反。 I applied a hover effect via jQuery and it just works fine on page load, but after using filters the hover effect simply stays visible on some images (not even every image is affected) and when I hover the hover-effect disappears. 我通过jQuery应用了一种悬停效果,并且在页面加载时效果很好,但是在使用过滤器后,悬停效果只是在某些图像上可见(甚至不影响所有图像),当我进行悬停时,悬停效果就会消失。 It's the exact opposite behaviour of what it's supposed to be. 这与预期的行为正好相反。

Can someone help me here? 有人可以帮我吗?

For explanation: 解释:

HTML 的HTML

 <ul class="filterable-grid">
        <li>
            <span class="portfolio-thumbnail">  
                <img src="#">
            </span>                             


            <span class="thumbnail-overlay">
                <div class="infotext">
                    <h4><a href="#">Title</a></h4>
                    <p>lorem ipsum</p>
                </div>
           </span>
        </li>
</ul>

jQuery jQuery的

$(document).ready(function() {
    $('.thumbnail-overlay').hide();
     $('.filterable-grid li').live('hover', function(){
          $(this).css('box-shadow', 'inset 0px 0px 55px -2px rgba(0,0,0,1)')
          $(this).find('.thumbnail-overlay').toggle('slow');
          return false;
     });
});

Alright, I found the problem. 好吧,我发现了问题。

Explanation: 说明:

The hover-effect would be visible on some items after using a filter, because I did not hide the .thumbnail-overlay <div> via CSS but jQuery. 使用过滤器后,某些项目上的悬浮效果将可见,因为我没有通过CSS隐藏.thumbnail-overlay <div> ,而是通过jQuery隐藏了。 So if I would use one of the filters, the code would already have been executed which means that my .hide() function does not affect portfolio items that are added dynamically. 因此,如果我使用其中一个过滤器,则该代码将已经执行,这意味着我的.hide()函数不会影响动态添加的投资组合项目。

Solution: 解:

I added display: none to .thumbnail-overlay in my CSS file. 我在我的CSS文件中向.thumbnail-overlay添加了display: none Then I changed my jQuery function to this: 然后我将jQuery函数更改为:

// Show Overlay on mouseover
    $('#main-content').on('mouseover', '#quicksand-portfolio li', function(){
        $(this).find('.thumbnail-overlay').stop().toggle('slow');    
    })

    $('#main-content').on('mouseout', '#quicksand-portfolio li', function(){
        $(this).find('.thumbnail-overlay').stop().toggle('slow');    
    })

The selector #main-content is the containig div, so it's an element that's not being dynamically changed when using a filter. 选择器#main-content是containig div,因此它是使用过滤器时不会动态更改的元素。

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

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