Jquery同位素过滤淡化了无与伦比的物品,而不是隐藏

Jquery同位素过滤淡化了无与伦比的物品,而不是隐藏。 在过滤不匹配的项目的情况下获得display none的属性。 我想显示匹配项应该自动向上滚动,其他应该向下滚动这样的内容http://base22.com/wps/portal/home/about-us/our-team

var $container = $('.portfolioContainer'); $container.isotope({ filter: '*', hiddenStyle: {opacity: 0.7}, visibleStyle: {opacity: 1}, animationOptions: { duration: 750, easing: 'linear', queue: false } }); $('.innermenu .list-inline li a').click(function() { $('.innermenu .list-inline li .current').removeClass('current'); $(this).addClass('current'); var selector = $(this).attr('post-category'); $container.isotope({ filter: selector, hiddenStyle: {opacity: 0.7}, visibleStyle: {opacity: 1}, itemPositionDataEnabled: true, animationOptions: { duration: 750, easing: 'linear', queue: false } }); return false; }); 
 .isotope-item { z-index: 2; } .isotope-hidden.isotope-item { pointer-events: none; z-index: 1; } .isotope, .isotope .isotope-item { /* change duration value to whatever you like */ -webkit-transition-duration: 0.8s; -moz-transition-duration: 0.8s; -ms-transition-duration: 0.8s; -o-transition-duration: 0.8s; transition-duration: 0.8s; } .isotope { -webkit-transition-property: height, width; -moz-transition-property: height, width; -ms-transition-property: height, width; -o-transition-property: height, width; transition-property: height, width; } .isotope .isotope-item { -webkit-transition-property: -webkit-transform, opacity; -moz-transition-property: -moz-transform, opacity; -ms-transition-property: -ms-transform, opacity; -o-transition-property: -o-transform, opacity; transition-property: transform, opacity; } /**** disabling Isotope CSS3 transitions ****/ .isotope.no-transition, .isotope.no-transition .isotope-item, .isotope .isotope-item.no-transition { -webkit-transition-duration: 0s; -moz-transition-duration: 0s; -ms-transition-duration: 0s; -o-transition-duration: 0s; transition-duration: 0s; } .isotope:after { content: ''; display: block; clear: both; } 
     
<div class="col-md-4 col-sm-4 col-xs-12 portfolio thumbnail-margin slug . $separator; } echo trim($output, $separator); } ?>">
<a href="https://stackoverflow.com/questions/25916873/jquery-isotope-filtering-fade-unmatched-items-instead-of-hiding/">

<?php get_footer();

顶行和所有其他元素的ed元素应该向下移动。

也许你可以用Dave Desandro的同位素隐藏揭示插件做一些事情,它不会显示:没有不匹配的项目,只会淡化到某个不透明度值。 然后,您可以根据需要设置可见和褪色项目的动画。

 $( function() { // init Isotope var $container = $('.your-container').isotope({ layoutMode: 'your-layout', itemSelector: '.your-item' }); /* some filter functions for example... var filterFns = { show if number is greater than 50 numberGreaterThan50: function() { var number = $(this).find('.number').text(); return parseInt( number, 10 ) > 50; }, show if name ends with -ium ium: function() { var name = $(this).find('.name').text(); return name.match( /ium$/ ); } };*/ // bind filter button click $('#filters').on( 'click', 'button', function() { var filterValue = $( this ).attr('data-filter'); // use filterFn if matches value filterValue = filterFns[ filterValue ] || filterValue; $container.hideReveal({ filter: filterValue }); }); // change is-checked class on buttons $('.button-group').each( function( i, buttonGroup ) { var $buttonGroup = $( buttonGroup ); $buttonGroup.on( 'click', 'button', function() { $buttonGroup.find('.current').removeClass('current'); $( this ).addClass('current'); }); }); }); // here you can add animations for your visible and hidden items $.fn.hideReveal = function( options ) { options = $.extend({ filter: '*', hiddenStyle: { opacity: 0.2 }, visibleStyle: { opacity: 1 }, }, options ); this.each( function() { var $items = $(this).children(); var $visible = $items.filter( options.filter ); var $hidden = $items.not( options.filter ); // reveal visible $visible.animate( options.visibleStyle ); // hide hidden $hidden.animate( options.hiddenStyle ); }); }; 

我首先会问你需要同位素的问题。 它并不是真的适用于那样的filter。 如果您需要布局并且无法使用flexbox或浮点数获得相同的效果,那么只需创建自己的过滤脚本来添加/删除项目中的active类,而不是尝试扩展同位素过滤。 css可以处理剩下的事情。 对于过滤我会说这样的事情:

  
Filtered 1
Filtered 2
Filtered 3
Filtered 4
Filtered 5

这仍然适用于同位素项集,只需更改jQuery和CSS中的选择器。

请注意,如果您的.active样式更改宽度或高度或其他间距属性,则必须调用$('.isotope').isotope('layout'); 再次在filter点击function结束时。