Using Enquire.JS to switch between scripts according to screen size

∥☆過路亽.° 提交于 2019-12-11 11:38:02

问题


I've made a page that has two different scripts. The script that runs is determined by the screen size. Enquire.Js is used to achieve this.

When the page is viewed on screen bigger than 600px, I want the content to be displayed with jQuery Tabs. I have made a test model here and it works fine: Live Page || JS Fiddle Version

Although it works, it only works one way. I.e. when the window is resized Enqiurie.js does its 'magic'. But if the window is re-sized again, the 'magic' is not reversed. (in contrast to a CSS media query where re-sizing the window again reverse the media query).

When the page is viewed on a screen smaller than 600px, I want it to be displayed with an iPhone style Nav. I have made a test model here and it also works fine: Live Page || JS Fiddle Version However, again it only works one way.

When I try to combine the two demos (i.e. so it switches between Tabs and iphone style Nav, it doesn't quite work. See the test model here: Live Page || JS Fiddle Version

If the browser is more than 600px on load, you have to refresh the window for the tabs to appear. If you reisze the window from less than 600px to more than 600px, some of the less-than-600px-code seems to persist.

I'm not sure what I am doing wrong. Thanks for any help!

来源:https://stackoverflow.com/questions/12808691/using-enquire-js-to-switch-between-scripts-according-to-screen-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!