1

我目前正在使用 enquire.js 来识别我的媒体查询,这些查询是:

breakpoints[extra_large_devices] = only screen and (min-width: 1098px);
breakpoints[large_devices] = (min-width: 992px);
breakpoints[medium_devices] = (min-width: 768px);
breakpoints[small_devices] = (min-width: 544px)
breakpoints[extra_small_devices] = (min-width: 0px);

我需要我的 js 为 medium_devices 触发,所以我写道:

Drupal.Breakpoints.register('medium_devices', {
  match: function() {
     console.log("match");
  },
  unmatch: function() {
     console.log("unmatch");
  },
});

所以从 0 到 767 我是无与伦比的。从 768 开始,我得到了匹配。问题是我希望 unmatch 也以 992px 触发。所以基本上我需要我的脚本从 768 到 991 工作,所以我需要识别“活动”媒体查询而不是 macth。任何想法如何解决这个问题?谢谢

4

0 回答 0