And so another Razorjack Quicksand for jQuery jumpy transition - jsfiddle provided

82 views Asked by At

When filtering with quicksand, all images starts with a jump before gliding into position. I have read a lot of q&a here, but I have not managed to get rid of this jump.

In the provided example/jsfiddle, the error is reproducable by these step-by-step:

  • Adjust window size so that the with contains two images. The output should show a grid of 2x2 images.
  • Press "All" to filter all (although all is already shown)
  • Press "Hard" to filter hard. The images now quickly "jump up" before sliding into position.

A jsfiddle is available here: https://jsfiddle.net/2kgu8c80/19/

External libraries:

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, 
        });
}
1

There are 1 answers

2
Rei On BEST ANSWER

The problem is the max-height: 100%; of .pzl_thumbs li. You need to remove that and let your li elements free to resize according to their contents.

Therefore, modify this:

.pzl_thumbs li,
.img_thumbs {
  background-color: transparent;
  display: block;
  max-height: 100%;
}

To this:

.pzl_thumbs li,
.img_thumbs {
  background-color: transparent;
  display: block;
}

If you need the max-height: 100%; for .img_thumbs, move it there instead:

.img_thumbs {
  height: 192px;
  max-height: 100%;
}

See https://jsfiddle.net/2kgu8c80/22/.