1
當使用流沙過濾時,所有圖像在跳入位置之前以跳轉開始。我在這裏讀了很多q &,但我還沒有設法擺脫這種跳躍。另一個Razorjack Quicksand for jQuery跳躍轉換 - jsfiddle提供
在所提供的例子/的jsfiddle,誤差是由這些可重放步驟一步:
- 調整窗口大小,以使與包含圖像。輸出應該顯示2×2圖像的網格。
- 按「全部」以全部過濾(雖然全部已顯示)
- 按「硬」過濾困難。在滑入位置之前,圖像現在快速「跳起來」。
一個的jsfiddle可以在這裏找到:https://jsfiddle.net/2kgu8c80/19/
外部庫:
HTML:
<head>
<title>My Wooden Puzzles</title>
<script src="https://code.jquery.com/jquery-3.0.0.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script type="text/javascript" src="quicksand/quicksand.min.js">/script>
</head>
<body>
<ul id="pzl_filter">
<li id="filter_hard"><a href="javascript:filter('all');">All</a></li>
<li id="filter_hard"><a href="javascript:filter('hard');">Hard</a></li>
<li id="filter_easy"><a href="javascript:filter('easy');">Easy</a></li>
</ul>
<div id="outer-wrapper">
<ul id="pzl_thumbs" class="pzl_thumbs">
<li id="pzl_main_chess_snake" data-id="chess_snake" class="pzl_d_hard">
<img src="http://www.mywoodenpuzzles.com/data/chess_snake/main_thumb.jpg" class="img_thumbs">
<dl><br><dd>Chass Snake</dd></dl></li>
<li id="pzl_main_triforce_2" data-id="triforce_2" class="pzl_d_easy"><a href="javascript:select_puzzle('triforce_2', 'pieces');"><img src="http://www.mywoodenpuzzles.com/data/triforce_2/main_thumb.jpg" class="img_thumbs">
<dl><br><dd>Triforce 2</dd></dl></a></li>
<li id="pzl_main_three_pieces_cross" data-id="three_pieces_cross" class="pzl_d_hard">
<img src="http://www.mywoodenpuzzles.com/data/three_pieces_cross/main_thumb.jpg" class="img_thumbs">
<dl><br><dd>3 pieces cross</dd></dl></li>
<li id="pzl_main_centrifuge" data-id="centrifuge" class="pzl_d_easy">
<img src="http://www.mywoodenpuzzles.com/data/centrifuge/main_thumb.jpg" class="img_thumbs">
<dl><br><dd>Centrifuge</dd></dl></li>
</ul>
</div>
</body>
CSS
/* Layout & items */
#outer-wrapper {
margin: 5px 20px;
}
.pzl_thumbs li,
.img_thumbs {
background-color: transparent;
display: block;
max-height: 100%;
}
.img_thumbs {
height: 192px;
}
.pzl_thumbs li {
float: left;
height: 215px;
margin: 10px 10px 30px 10px;
}
.pzl_thumbs ul {
float: left;
}
.pzl_thumbs dd {
color: #666666;
font-size: 14px;
text-align: center;
}
的JavaScript
var $list = jQuery("#pzl_thumbs");
var $data = $list.clone();
var $filteredData = null;
function filter(difficulty) {
var sel = ((difficulty!='all')? 'li.pzl_d_' + difficulty : 'li') ;
$filteredData = $data.find(sel);
$list.quicksand($filteredData, {
duration: 1800,
adjustHeight: false,
});
}
謝謝!我很高興得到一個完美的答案!我只是想告訴你,StackOverflow告訴我必須再過8個小時才能給你賞金。 –
@AndreasLundgren不客氣。我很樂意提前幫助和感謝賞金。 – Rei