首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用jQuery Quicksand过滤时出现笨拙的跳转

使用jQuery Quicksand过滤时出现笨拙的跳转
EN

Stack Overflow用户
提问于 2012-06-06 06:10:35
回答 2查看 2.3K关注 0票数 0

我正在使用流沙和jquery开发一个可过滤的站点。我已经设置好了所有东西(img现在是通用的)。

链接为http://lllh.dk/filtering/work3.html

html的一部分:

代码语言:javascript
复制
<div id="content">
    <div class="txtdiv">
    <h1>A selection of work</h1>
    <h2>2009-present</h2>
    </div>

        <div id="workleft">

            <ul class="filterOptions">  
              <txt>
                <li class="active"><a href="#" class="all">All</a></li>
                <li><a href="#" class="graphicdesign">Graphic Design</a></li>
                <li><a href="#" class="printmatters">Design of Printed Matters</a></li>
                <li><a href="#" class="designlanguages">Design for Languages</a></li>
                <li><a href="#" class="typo">Typography and Lettering</a></li>
                <li><a href="#" class="visualidentity">Visual Identity</a></li>
              </txt>
            </ul>
        </div>

        <div id="workright">
            <ul class="filterOptions">  
              <txt>
                <li><a href="#" class="photo">Photography</a></li>
                <li><a href="#" class="camless">Cameraless Photography</a></li>
                <li><a href="#" class="co-socialdesign">Co-Design / Social Design</a></li>
                <li><a href="#" class="conceptualdesign">Conceptual Design</a></li>
                <li><a href="#" class="criticaldesign">Critical Design</a></li>
              </txt>
            </ul>
        </div>

    <div class="workdiv">

    <ul class="ourHolder">

<li class="item" data-id="id-1" data-type="graphicdesign typo">
<a href="work/braille_calendar.html" onMouseOver="document.braille.src='workbuttons/braille2.jpg';" onMouseOut="document.braille.src='workbuttons/braille1.jpg';"> <img src="workbuttons/braille1.jpg" name="braille"> </a>
</li>
<li class="item" data-id="id-3" data-type="camless photo">
<a href="work/braille_calendar.html" onMouseOver="document.RapaNui.src='workbuttons/braille2.jpg';" onMouseOut="document.RapaNui.src='workbuttons/braille1.jpg';"> <img src="workbuttons/braille1.jpg" name="RapaNui"> </a>
</li>

<li class="item" data-id="id-2" data-type="graphicdesign">
<a href="work/braille_calendar.html" onMouseOver="document.Name.src='workbuttons/braille2.jpg';" onMouseOut="document.Name.src='workbuttons/braille1.jpg';"> <img src="workbuttons/braille1.jpg" name="Name"> </a>
</li>
<li class="item" data-id="id-2" data-type="typo">
<a href="work/braille_calendar.html" onMouseOver="document.Something.src='workbuttons/braille2.jpg';" onMouseOut="document.Something.src='workbuttons/braille1.jpg';"> <img src="workbuttons/braille1.jpg" name="Something"> </a>
</li>           
    </ul>
    </div>  
</div>

和一些css

代码语言:javascript
复制
/* Load headline fonts */
@font-face {
 font-family: 'ACPRegular';
 src: url('acaslonpro-regular-webfont.eot');
 src: url('acaslonpro-regular-webfont.eot?#iefix') format('embedded-opentype'),
     url('acaslonpro-regular-webfont.woff') format('woff'),
     url('acaslonpro-regular-webfont.ttf') format('truetype');
 font-weight: normal;
 font-style: normal;
}
@font-face {
 font-family: 'ACPBold';
 src: url('acaslonpro-bold-webfont.eot');
 src: url('acaslonpro-bold-webfont.eot?#iefix') format('embedded-opentype'),
     url('acaslonpro-bold-webfont.woff') format('woff'),
     url('acaslonpro-bold-webfont.ttf') format('truetype');
 font-weight: normal;
 font-style: normal;
}

/* Page content */
#content {
margin-top:75px;
position:absolute;
width:850px;
z-index:0;
border-bottom:45px;
border-bottom-style:solid;
border-bottom-color:#FFF;
}

.txtdiv {
width:400px;
margin: 0px auto 0px auto;
text-align:center;
}

/* Typography */

h1 {
font-family:ACPBold;
letter-spacing:1px;
font-size:2em;
font-weight:normal;
padding:0px;
margin:0px;
margin-bottom:3px;
}

h2 {
font-family:ACPRegular;
font-size:1.2em;
font-weight:normal;
padding:0px;
margin-top:0px;
margin-bottom:15px;
}

txt {
font-family:Arial, Helvetica, sans-serif;
font-size:0.7em;
line-height:160%;
margin-left:auto;
margin-right:auto;
}

ul {
list-style-type: none;
padding: 0px;
margin: 0px;
overflow: auto;
}

/* Work page */
#workleft {
width:421px;
margin: 0px 8px 0px 0px;
text-align:right;
float:left;
}

#workright {
width:421px;
text-align:left;
overflow:hidden;
}


.workdiv {
width:741px;
margin: 0px auto 0px auto;
margin-top:45px;
}

/*- PORTFOLIO -*/
ul.ourHolder {
width: 800px;
height: 850px;
overflow: hidden;
}
ul.ourHolder li.item {
width: 247px;
height: 164px;
float: left;
text-align: center;
overflow: hidden;
}

最后是js..

代码语言:javascript
复制
$(document).ready(function() {
  // get the action filter option item on page load
  var $filterType = $('.filterOptions li.active a').attr('class');

  // get and assign the portfolio element to the
// $holder varible for use later
  var $holder = $('ul.ourHolder');

  // clone all items within the pre-assigned $holder element
  var $data = $holder.clone();

  // attempt to call Quicksand when a filter option
// item is clicked
$('.filterOptions li a').click(function(e) {
    // reset the active class on all the buttons
    $('.filterOptions li').removeClass('active');

    // assign the class of the clicked filter option
    // element to our $filterType variable
    var $filterType = $(this).attr('class');
    $(this).parent().addClass('active');

    if ($filterType == 'all') {
        // assign all li items to the $filteredData var when
        // the 'All' filter option is clicked
        var $filteredData = $data.find('li');
    } 
    else {
        // find all li elements that have our required $filterType
        // values for the data-type element
        var $filteredData = $data.find('li[data-type~=' + $filterType + ']');
    }

    // call quicksand and assign transition parameters
    $holder.quicksand($filteredData, {
        duration: 800,
        easing: 'easeInOutQuad'
    });
    return false;
});
});

似乎在某种程度上,布局的一部分打乱了放松。在我尝试进行故障排除的过程中,似乎是图像上方的某个部分出了问题,可能是txtdiv div。如果我删除除应用于filter函数的css之外的所有css,则缓动和过滤都可以正常工作。

EN

回答 2

Stack Overflow用户

发布于 2012-06-06 06:20:56

我知道这个问题。这里已经有一个问题了:CSS bubbling while using jQuery Quicksand

对我来说,当我更改多个css行时,它是有效的。但我不知道了,也许你可以看看源代码:http://www.annagebhardt.de/ (要查看效果,请点击'PROJEKTE‘,然后点击一个子条目)

票数 0
EN

Stack Overflow用户

发布于 2012-06-06 07:33:21

注释掉$(this).parent().addClass('active');并将adjustHeight: false添加到流沙的选项中对我来说很管用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10905699

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档