I have the JavaScript below and it only runs when the width of the screen is under 1024px which is what I want and it works fine. However I really need to make it run when only the width of the screen is below 1024px AND when the following style-sheet is called: <link rel="stylesheet" media="screen and (max-width: 1024px) and (-webkit-min-device-pixel-ratio: 1.25),(min-resolution: 120dpi)" href="assets/css/tablet-and-mobile.css" />
//Apply swipping//
function applySnap() {
var width = window.innerWidth;
if (width <= 1024) {
if (window.snap) {
window.snap.enable();
} else {
window.snap = new Snap({
element: document.getElementById('page')
});
}
} else {
if (window.snap) {
window.snap.disable();
if( window.snap.state().state !=='closed' ){
window.snap.close();
}
}
}
//Close slider when orientation changes//
window.addEventListener("orientationchange", function () {
if (window.snap.state().state !== 'closed') {
window.snap.close( 0 );
}
}, false);
}
window.onresize = applySnap;
applySnap();
//Swipping (Open/Close Button)//
$('.secondHeader-menuButton').on('click', function (e) {
e.preventDefault();
if (window.snap.state().state === "closed") {
window.snap.open('left');
} else {
window.snap.close('left');
}
});
Why? right it is really complex but take a look at my previous question HERE As you can see I am using the solution but also did this:
<link rel="stylesheet" type="text/css" href="assets/css/core.css">
<link rel="stylesheet" media="screen and (max-width: 1024px) and (-webkit-min-device-pixel-ratio: 1.25),(min-resolution: 120dpi)" href="assets/css/tablet-and-mobile.css" />
<link rel="stylesheet" media="screen and (max-width: 1000px)" href="assets/css/tablet-and-mobile.css" />
That fixed the problem! however I have a sliding navigation that need to be shown only on tablets, ie when the tablet-and-mobile.css is enabled only! but because I have the following line: <link rel="stylesheet" media="screen and (max-width: 1000px)" href="assets/css/tablet-and-mobile.css" />
the slider js will run as it runs when the screen size is below 1024px.