gpt4 book ai didi

javascript - 同位素排序回调函数

转载 作者:行者123 更新时间:2023-12-03 11:48:32 25 4
gpt4 key购买 nike

我正在使用 Isotope jquery 插件按名称或日期对列表中的多个文件进行排序。同位素函数运行完美,但我需要在排序后运行回调函数,但我不知道在哪里触发它。

这是迄今为止我的同位素代码:

function animationFinished() {
$('#isotope-container a').each(function(index, element) {
var top = parseInt($(element).css('top')); console.log(top);
});
}

var $container = $('#isotope-container').isotope({
getSortData: {
name: '[title]',
date: function( itemElem ) { // function
var date = $( itemElem ).attr('year');
return parseInt(date);
}
}
});
$('#sorting').change( function() {
//console.log('click');
var sortByValue = $(this).find('option:selected').attr('data-sort-by');
$container.isotope({ sortBy: sortByValue });
});

这是一个正在排序的 html 的小示例

<div id="sorts" class="button-group">
<p>Sort by:
<select id="sorting">
<option data-sort-by="name">Name</option>
<option data-sort-by="date">Date</option>
</select></p>
</div>

<div id="isotope-container">
<a title="Army Corps of Engineers" year="2009" href="/army-corp-of-engineers-tom-river-rehab-nj-2009/">Army Corp of Engineers</a>
<a year="1999" title="Bolted Steel NSF Tank A6 &amp; A7" href="/bolted-steel-nsf-tank-a6-a7-houston-1999/">Bolted Steel</a>
<a year="1998" title="Brick Manhole Raven 405" href="/brick-manhole-raven-405-charleston-1998/">Brick Manhole</a>
<a year="9999" title="Wetwell Vault Rehab" href="/wetwell-vault-rehab/">Wetwell Vault</a>
</div>

最佳答案

同位素 v2

http://isotope.metafizzy.co/events.html

$container.isotope( 'on', 'layoutComplete', function(){ … } ); //only set this up once

$container.isotope({ sortBy: sortByValue });

同位素 v1

http://isotope.metafizzy.co/v1/tests/callbacks.html

$container.isotope({ sortBy: sortByValue }, function(){ … });

关于javascript - 同位素排序回调函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25940582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com