javascript - jquery 同位素过滤器完成后触发警报

标签 javascript jquery jquery-plugins jquery-isotope

我有 jquery 同位素设置并创建了一些过滤器。当我创建我选择一个过滤器时,同位素会做一个漂亮的小动画。我想在动画结束时触发警报。

这个例子演示了发生的动画:

http://isotope.metafizzy.co/demos/filtering.html

有什么想法吗?

这是点击过滤器的代码:

$('.filter').on( 'click', 'a', function( event ) {
        event.preventDefault();
        var $this = $(this);
        // don't proceed if already selected
        if ( $this.hasClass('selected') ) {
            return false;
        }

        // console.log('hello world');
        var $optionSet = $this.parents('.option-set');
        var group = $optionSet.attr('data-filter-group');
        options.comboFilters[ group ] = $this.attr('data-filter-value');
        $.bbq.pushState( options );

        // COUNT
        var $filtered = $('#isotope-container').data('isotope').$filteredAtoms;
        // get count of all filtered item
        alert($filtered.length);
        // get count of all filtered items that match a selector
        //$filtered.filter('.blue').length;
  });

最佳答案

从 v1.5 ( changelog ) 开始,Isotope 提供了一个回调来做到这一点;在 Isotope's Introduction 中有描述(只需在页面中搜索 callback):

Additionally you can specify a callback after the options object. This function will be triggered after the animation has completed.

onAnimationFinished = function(){
  // code to be executed after the animation finishes
};

$('#container').isotope({ filter: '.my-selector' }, onAnimationFinished);

有关实际示例,请查看 this jsFiddle通过复选框输入或窥视更改过滤器时会引发警报 Isotope's Callback Test来源并搜索 changeBGColor

关于javascript - jquery 同位素过滤器完成后触发警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12715533/

相关文章:

jquery - 是否有 Superfish 的替代 jQuery 菜单插件?

javascript - 属性更改后重新将 jquery 插件绑定(bind)到选择器?

jquery-plugins - 如何将 SlimScroll 应用于 Body 元素?

javascript - 每次 div 改变其大小时如何运行一个函数?

javascript - 提交表单时不显示错误类

javascript - JS 代码中的加号 - 为什么它们在这里不是可选的

jquery - 在 jquery 中使用动态添加的元素

javascript - window.parent.location.href 或 window.top.location 哪个更好

javascript - 组件 'div' 的 View 配置 getter 回调必须是一个函数(收到 'undefined' )。确保组件名称以大写字母开头

javascript - ng-model 未因 $http 调用而更新