图库滤镜插件“Filterizr”——混合滤镜模式

Gallery filter plugin 'Filterizr" - mix filter mode

我正在尝试实现 Filterizr 插件(https://yiotis.net/filterizr/#/tutorials/quickstart) on my project, and i need exactly mix filter as presented on this tutorial page https://yiotis.net/filterizr/#/tutorials/filtering

如果单击屏幕截图中显示的混合按钮,我们只会看到橙色和紫红色块 - 这正是我所需要的,但它不起作用。

我使用该插件构建了自己的演示,但仍然无法正常工作。

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/filterizr/2.2.4/jquery.filterizr.min.js"></script>
    <title>Hello, world!</title>
  </head>
  <body>
    <h1>filter</h1>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
    
    <div class="container">
        <div style="cursor:pointer;" class="col-md-12 col-xs-12">
            <ul>
                <li data-filter="all">All</li>
                <li data-filter="1">1</li>
                <li data-filter="2">2</li>
                <li data-filter="1,2">1 and 2</li>
            </ul>
        </div>
    </div>
  <h1>items</h1>
     <div style="margin: 40px;" class="row filtr-container">
     
         <div style="border: 4px black;" class="col-md-2 col-sm-6 filtr-item"  data-category="all,1">
         <span>1</span>
         </div>
         
         <div style="border: 4px black;" class="col-md-2 col-sm-6 filtr-item"  data-category="all,2">
         <span>2</span>
         </div>
                 
         <div style="border: 4px black;" class="col-md-2 col-sm-6 filtr-item"  data-category="all">
         <span>3</span>
         </div>
         
     </div>
    <script>
    $('.filtr-container').filterizr({});
    </script>
    
  </body>
</html>

如果单击“1 和 2”过滤器 - 预计会看到 1 和 2 项,如本 https://yiotis.net/filterizr/#/tutorials/filtering 中的示例 - 混合 ,但无法正常工作。我被卡住了,需要一些建议。

看来我找到了解决方案 =) - 迁移 Shuffle.js (https://vestride.github.io/Shuffle/faq)

对于这个插件,它工作正常,而且看起来它可以免费用于商业用途。

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Shuffle/5.4.1/shuffle.min.js" integrity="sha512-26vtWkj1Yt/eY2Ykb7TO/RzzysOKS7zaD/055jS+2IW4DX89qlH/HziTFqfzMLAxpFVpYhPWgTdCcavzf8Qs8g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <title>Hello, world!</title>
  </head>
  <style>
  #grid {margin-left:-5px;margin-right:-5px;position:relative; overflow: hidden;}
  #grid [class*="col-"] {padding:5px;}

@media (max-width:320px) {
   #grid [class*="col-"] {width:100%;}
}


.shuffle_sizer {
  position: absolute;
  opacity: 0;
  visibility: hidden;
}
  </style>
  <body>
    <h1>filter</h1>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
    
    <div class="container">
        <div style="cursor:pointer;" class="col-md-12 col-xs-12 filter-options">
            <ul class>
                <li data-group='["all"]'>All</li>
                <li data-group='["1"]'>1</li>
                <li data-group='["2"]'>2</li>
                <li data-group='["1","2","prem"]'>1 and 2 and prem</li>
            </ul>
        </div>
    </div>
  <h1>items</h1>
     <div style="margin: 40px;" id="grid" class="row">
     
         <div style="border: 4px black;" class="col-md-2 col-sm-6 filtr-item"  data-groups='["all","1"]'>
         <span>1</span>
         </div>
         
         <div style="border: 4px black;" class="col-md-2 col-sm-6 filtr-item"  data-groups='["all","2"]'>
         <span>2</span>
         </div>
                 
         <div style="border: 4px black;" class="col-md-2 col-sm-6 filtr-item"  data-groups='["all"]'>
         <span>3</span>
         </div>
         
         <div style="border: 4px black;" class="col-md-2 col-sm-6 filtr-item"  data-groups='["all","prem"]'>
         <span>prem</span>
         </div>
         
               <!-- sizer -->
      <div class="col-xs-6 col-sm-4 col-md-3 shuffle_sizer"></div>  
         
     </div>
    <script>
    var Shuffle = window.Shuffle;
var $grid = $('#grid');
var sizer = $grid.find('.shuffle_sizer');

var shuffleInstance = new Shuffle($grid, {
  itemSelector: '.filtr-item',
  sizer: sizer // could also be a selector: '.shuffle_sizer'
});

$('.filter-options').on('click','li',function(){
     let currFilterName = $(this).data('group');
     shuffleInstance.filter(currFilterName);
});
    </script>
    
  </body>
</html>