简体   繁体   English

Isotope.js:显示隐藏的项目

[英]Isotope.js: reveal hidden items

I'm using Isotope v2 & having some trouble revealing previously hidden items. 我正在使用Isotope v2,在显示以前隐藏的项目时遇到了一些麻烦。 I'm not sure what I'm doing wrong. 我不确定自己在做什么错。

To start, I'm gathering an array of jQuery objects & telling Isotope to hide them. 首先,我要收集一组jQuery对象并告诉Isotope隐藏它们。 This works perfectly: 这完美地工作:

elements.postsToHide.push($(elements.gridBlock + "#" + v.SocialPostId)); // $(".block#block123")
elements.grid.isotope("hide", elements.postsToHide).isotope();

Eventually, I'd like to reveal these hidden items again. 最终,我想再次展示这些隐藏的物品。 So, on click of a button, I'm doing the following, which does not reveal anything: 因此,在单击按钮时,我正在执行以下操作,但不会显示任何内容:

elements.grid.isotope("reveal", elements.postsToHide);

The docs say "hide" & "reveal" take and Array of Isotope.Items, which I believe I'm passing properly. 文档说 “隐藏”和“显示”,以及Isotope.Items数组,我相信我传递的正确。

When I call the reveal method, my console says "Uncaught Error: undefined is not a function". 当我调用揭示方法时,控制台会显示“未捕获的错误:未定义不是函数”。

I'm perplexed as to why I can push into an array and hide items, but the same array cannot be revealed. 我困惑为什么可以推入数组并隐藏项目,但无法显示同一数组。

According to this issue request, Isotope/Masonry hide and reveal methods are mostly internal and aren't the easiest to use. 根据此问题的要求,同位素/砌体的hidereveal方法大部分是内部的,并不是最容易使用的方法。

To get around the issues I was having was to: 解决我遇到的问题是:

  1. push items to hide into an array 推送项目以隐藏到数组中
  2. each through the items and use jQuery .hide() 每个项目,并使用jQuery .hide()
  3. once each is done, call .isotope() again to layout grid with newly hidden items 每次完成后,再次调用.isotope()以使用新隐藏的项目布局网格
  4. to reveal, each through the items and use jQuery .show , then call .isotope again 揭示每个项目,并使用jQuery .show ,然后再次调用.isotope

i did something like this 我做了这样的事情

        //swipe.
    $('.grid').on('swiperight', '.grid-item', function(event) {
        $(this).hide().fadeOut('500', function() {
            $('.grid').isotope('hide', this).isotope('layout');
        });
    });

    $('.filter-button-group').on( 'click', 'button', function() {
        $(this).parent().parent().next().find('.grid-item').show().fadeIn('slow', function() {
            $('.grid').isotope('reveal', this).isotope('layout');
        });
    });

i used hide/show before calling the method 我在调用方法之前使用了隐藏/显示

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

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