I am utilizing jQuery mobile to build a sidepanel. Here is my code that incorporates swipe functionality to reveal the sidepanel:
$( document ).on( "pagecreate", "#swipe-page", function() {
$( document ).on( "swipeleft swiperight", "#swipe-page", function( e ) {
// Ensuring that only one panel opens when swiping
if ( $( ".ui-page-active" ).jqmData( "panel" ) !== "open" ) {
if ( e.type === "swipeleft" ) {
$( "#right-panel" ).panel( "open" );
} else if ( e.type === "swiperight" ) {
$( "#left-panel" ).panel( "open" );
}
}
});
});
I want this swipe feature to be active only when the viewport width is 480px or higher. How can I implement this condition? In CSS, this would typically be handled through a media query.