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

Commit c8eb941

Browse files
author
Ian Maffett
committed
make slide menu plugin block scrolling at all times.
1 parent 94258c4 commit c8eb941

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

plugins/af.slidemenu.js

+24-13
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
$.ui.ready(function() {
2121

2222
if ($.os.ie) return; //ie has the menu at the bottom
23-
23+
var afui=$("#afui").get(0);
2424
var elems = $("#content, #header, #navbar");
2525
var max = 0;
2626
var slideOver = max/3;
@@ -33,7 +33,8 @@
3333
var asideWidth = $asideMenu.width();
3434
var inputElements = ["input", "select", "textarea"];
3535
var tracking=false;
36-
$("#afui").bind("touchstart", function(e) {
36+
var hasMoved=false;
37+
afui.addEventListener("touchstart", function(e) {
3738
openState=0;
3839
if (!$.ui.isSideMenuEnabled() && !$.ui.isAsideMenuEnabled()) return true;
3940
if(e.touches.length>1) return;
@@ -65,9 +66,10 @@
6566
openState=2;
6667
max = asideWidth;
6768
}
68-
});
69+
},true);
70+
71+
afui.addEventListener("touchmove", function(e) {
6972

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

7880
//splitview stuff
81+
if(hasMoved){
82+
e.preventDefault();
83+
e.stopPropagation();
84+
}
7985

8086
if($.ui.splitview&&window.innerWidth>=parseInt($.ui.handheldMinWidth,10)&& (dx > startX)&&openState===0) return true;
8187
if (!$.ui.isSideMenuEnabled() && (dx > startX) && openState===0) return true;
82-
if (!$.ui.isAsideMenuEnabled() && (dx < startX) && openState===0) return true;
83-
88+
if (!$.ui.isAsideMenuEnabled() && (dx < startX) && openState===0) return true;
8489
if (Math.abs(dy - startY) > Math.abs(dx - startX)) return true;
8590

8691
if (!checking) {
@@ -90,7 +95,6 @@
9095
}
9196
else
9297
doMenu=true;
93-
9498
var thePlace = (dx - startX);
9599
if(openState===0){
96100
if(thePlace<0){
@@ -104,8 +108,13 @@
104108
$asideMenu.hide();
105109
}
106110
}
107-
if (Math.abs(thePlace) > max) return true;
108111

112+
if (Math.abs(thePlace) > max){
113+
return true;
114+
}
115+
116+
e.preventDefault();
117+
e.stopPropagation();
109118
slideOver=max/3;
110119
showHideThresh=Math.abs(thePlace)<slideOver?showHide?showHide:false:2;
111120

@@ -134,20 +143,22 @@
134143
} else {
135144
isAside=false;
136145
}
146+
hasMoved=true;
137147
elems.cssTranslate(thePlace + "px,0");
138-
e.preventDefault();
139-
e.stopPropagation();
140-
});
141-
$("#afui").bind("touchend", function(e) {
148+
149+
150+
},true);
151+
afui.addEventListener("touchend", function(e) {
142152
if (!$.ui.isSideMenuEnabled() && !$.ui.isAsideMenuEnabled()) return true;
143153
if (doMenu && checking&&!keepOpen) {
144154
$.ui.toggleSideMenu(showHideThresh, function(){
145155
}, transTime,isAside);
146156
}
157+
hasMoved=false;
147158
checking = false;
148159
doMenu = false;
149160
keepOpen=false;
150161
tracking=false;
151-
});
162+
},true);
152163
});
153164
})(af);

0 commit comments

Comments
 (0)