Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
make slide menu plugin block scrolling at all times.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Maffett committed Apr 1, 2014
1 parent 94258c4 commit c8eb941
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions plugins/af.slidemenu.js
Expand Up @@ -20,7 +20,7 @@
$.ui.ready(function() {

if ($.os.ie) return; //ie has the menu at the bottom

var afui=$("#afui").get(0);
var elems = $("#content, #header, #navbar");
var max = 0;
var slideOver = max/3;
Expand All @@ -33,7 +33,8 @@
var asideWidth = $asideMenu.width();
var inputElements = ["input", "select", "textarea"];
var tracking=false;
$("#afui").bind("touchstart", function(e) {
var hasMoved=false;
afui.addEventListener("touchstart", function(e) {
openState=0;
if (!$.ui.isSideMenuEnabled() && !$.ui.isAsideMenuEnabled()) return true;
if(e.touches.length>1) return;
Expand Down Expand Up @@ -65,9 +66,10 @@
openState=2;
max = asideWidth;
}
});
},true);

afui.addEventListener("touchmove", function(e) {

$("#afui").bind("touchmove", function(e) {
if(e.touches.length>1||!tracking) return;
if (!$.ui.isSideMenuEnabled() && !$.ui.isAsideMenuEnabled()) return true;
if (!$.ui.slideSideMenu||keepOpen) return true;
Expand All @@ -76,11 +78,14 @@
dy = e.touches[0].pageY;

//splitview stuff
if(hasMoved){
e.preventDefault();
e.stopPropagation();
}

if($.ui.splitview&&window.innerWidth>=parseInt($.ui.handheldMinWidth,10)&& (dx > startX)&&openState===0) return true;
if (!$.ui.isSideMenuEnabled() && (dx > startX) && openState===0) return true;
if (!$.ui.isAsideMenuEnabled() && (dx < startX) && openState===0) return true;

if (!$.ui.isAsideMenuEnabled() && (dx < startX) && openState===0) return true;
if (Math.abs(dy - startY) > Math.abs(dx - startX)) return true;

if (!checking) {
Expand All @@ -90,7 +95,6 @@
}
else
doMenu=true;

var thePlace = (dx - startX);
if(openState===0){
if(thePlace<0){
Expand All @@ -104,8 +108,13 @@
$asideMenu.hide();
}
}
if (Math.abs(thePlace) > max) return true;

if (Math.abs(thePlace) > max){
return true;
}

e.preventDefault();
e.stopPropagation();
slideOver=max/3;
showHideThresh=Math.abs(thePlace)<slideOver?showHide?showHide:false:2;

Expand Down Expand Up @@ -134,20 +143,22 @@
} else {
isAside=false;
}
hasMoved=true;
elems.cssTranslate(thePlace + "px,0");
e.preventDefault();
e.stopPropagation();
});
$("#afui").bind("touchend", function(e) {


},true);
afui.addEventListener("touchend", function(e) {
if (!$.ui.isSideMenuEnabled() && !$.ui.isAsideMenuEnabled()) return true;
if (doMenu && checking&&!keepOpen) {
$.ui.toggleSideMenu(showHideThresh, function(){
}, transTime,isAside);
}
hasMoved=false;
checking = false;
doMenu = false;
keepOpen=false;
tracking=false;
});
},true);
});
})(af);

1 comment on commit c8eb941

@manuelwenner
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Ian,

you are simply the best man :) It works perfect for Android and in Chrome too!
Actually i am working at an issue, so that you can only swipe the slide menu if you start at position leftmost.
I will report you if it's finished.

Many greetings from Germany

Please sign in to comment.