javascript - 如何更改调整窗口大小的 javascript 选项?

标签 javascript media-queries jquery-events jquery-isotope window-resize

当我将移动设备的窗口大小调整为 500 像素时,我需要在脚本中更改一个选项。一定很简单,但我无法做到。当窗口大小为 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;
}
});

希望有人能帮助我。

最佳答案

使用 onresize 事件

window.onresize = function() {
  if (screen.width <= 500) {
   console.log("do something");
  }
}

关于javascript - 如何更改调整窗口大小的 javascript 选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50233107/

相关文章:

javascript - 在 JavaScript 中重新定义事件

javascript - Laravel 加载本地 css 和 js 资源非常慢

html - 媒体查询 - 通用响应模板

css - 如何针对 IE10+ 和特定屏幕尺寸?

html - Safari 7 中的 CSS 布局问题

javascript - Hashchange jQuery 插件 - 单击 anchor 时获取当前哈希值

javascript - 设置 cookie 不适用于 Javascript 或 jQuery

javascript - 添加 onclick 函数到我的表的每一行只记录最后一行

javascript - 底部的 Owl Carousel 进度条?

javascript - 如何在 html javascript 中验证 google maps api key ?