当我将窗口调整为500px移动设备时,我需要更改脚本中的选项。必须简单,但我无法管理它。当窗口大小为500px时,我需要'fitWidth:true'为'false'。
以下是代码:
// init Isotope
var $grid = $('#container').isotope({
itemSelector: '.element',
masonry: {
columnWidth: '.element',
fitWidth: true,
horizontalOrder: true
},
filter: function() {
var $this = $(this);
var searchResult = qsRegex ? $this.text().match( qsRegex ) : true;
var buttonResult = buttonFilter ? $this.is( buttonFilter ) : true;
return searchResult && buttonResult;
}
});
希望有人能帮助我,并提前致谢!
答案 0 :(得分:1)
使用onresize事件
window.onresize = function() {
if (screen.width <= 500) {
console.log("do something");
}
}