切换jQuery按钮时跳转内容
问题描述:
当我切换过滤器“CM”,在第2,3和4行,内容跳跃,我不知道为什么。切换jQuery按钮时跳转内容
$(document).ready(function() {
$('.filter_content').mixItUp({
controls: {
enable: false // we won't be needing these
},
animation: {
enable: false
},
callbacks: {
onMixLoad: function(){
$(this).mixItUp('setOptions', {
animation: {
enable: true,
duration: 400,
effects: 'fade',
easing: 'ease'
},
});
}
}
});
});
你能不能帮我解决这个问题?
答
我对mixitup不是很熟悉,但它看起来像是因为你将mixitup应用于filter_content,它包含所有选项,它会将所有选项推到顶端。在这里,我将它附加到模型上,它将起作用,但是现在,当列没有您要过滤的对象时,就会在MixFail上触发。如果您需要查看哪些列没有该选项,则可以使用state。$ targets.context在onMixFail事件中抓取它。
$(document).ready(function() {
// Initialize buttonFilter code
buttonFilter.init();
// Instantiate MixItUp
$('.model').mixItUp({
controls: {
enable: false // we won't be needing these
},
animation: {
enable: false
},
callbacks: {
onMixLoad: function(){
$(this).mixItUp('setOptions', {
animation: {
enable: true,
duration: 400,
effects: 'fade',
easing: 'ease'
},
});
},
onMixFail: function(state){
//fires when there are no matches
console.log(state.$targets.context);
console.log(state);
}
}
});
});
感谢的人,在onMixFail功能对我来说并不重要。现在的另一个问题是,如果按下滤波器CM,第三行中的单个元素会产生振动,但是为什么? – fr3d
@ fr3d我不太确定,但我认为这与mixitup试图将该项目移动到容器的顶部有关,因为容器正在缩小,因为其他项目被滤除。 – spaniol6