admin管理员组文章数量:1026989
I have it disabled already, and I can enable it again. I used:
document.ontouchmove = function(e){
e.preventDefault();
}
In the document.ready(); to disable it.
And I used this to enable it.
function doTouchMove(state) {
document.ontouchmove = function(e){
return state;
}
}
I have it so when a user double clicks on an element, the doTouchMove is called. But how do I make it disabled again?
Thanks
I have it disabled already, and I can enable it again. I used:
document.ontouchmove = function(e){
e.preventDefault();
}
In the document.ready(); to disable it.
And I used this to enable it.
function doTouchMove(state) {
document.ontouchmove = function(e){
return state;
}
}
I have it so when a user double clicks on an element, the doTouchMove is called. But how do I make it disabled again?
Thanks
Share Improve this question edited Aug 23, 2010 at 13:37 cat asked Aug 23, 2010 at 13:30 catcat 1,5975 gold badges15 silver badges15 bronze badges2 Answers
Reset to default 2You could create a toggle instead, where your doTouchMove() function switches between false and true every time it's called:
(function () { // Set up a closure so we don't pollute the global scope
var state = false;
function doTouchMove() {
state = !state;
}
document.ontouchmove = function(e){
return state;
}
document.getElementById("myDoubleClickElement").ondblclick = doTouchMove;
})();
Now, every time you double-click #myDoubleClickElement, it will toggle the state variable's value between false and true, effectively disabling on the even clicks and enabling on the odd clicks.
Im the same user who asked this question... but I cleared my history & everything so I can't pick an answer or anything!
But what I did to fix it was put this
document.ontouchmove = function(e){
e.preventDefault();
}
Into its own function, just as the doTouchMove() was. Then when I wanted it to stop moving again i would just call the name of that preventDefault function.
I don't know why it makes a difference but it works! :)
I have it disabled already, and I can enable it again. I used:
document.ontouchmove = function(e){
e.preventDefault();
}
In the document.ready(); to disable it.
And I used this to enable it.
function doTouchMove(state) {
document.ontouchmove = function(e){
return state;
}
}
I have it so when a user double clicks on an element, the doTouchMove is called. But how do I make it disabled again?
Thanks
I have it disabled already, and I can enable it again. I used:
document.ontouchmove = function(e){
e.preventDefault();
}
In the document.ready(); to disable it.
And I used this to enable it.
function doTouchMove(state) {
document.ontouchmove = function(e){
return state;
}
}
I have it so when a user double clicks on an element, the doTouchMove is called. But how do I make it disabled again?
Thanks
Share Improve this question edited Aug 23, 2010 at 13:37 cat asked Aug 23, 2010 at 13:30 catcat 1,5975 gold badges15 silver badges15 bronze badges2 Answers
Reset to default 2You could create a toggle instead, where your doTouchMove() function switches between false and true every time it's called:
(function () { // Set up a closure so we don't pollute the global scope
var state = false;
function doTouchMove() {
state = !state;
}
document.ontouchmove = function(e){
return state;
}
document.getElementById("myDoubleClickElement").ondblclick = doTouchMove;
})();
Now, every time you double-click #myDoubleClickElement, it will toggle the state variable's value between false and true, effectively disabling on the even clicks and enabling on the odd clicks.
Im the same user who asked this question... but I cleared my history & everything so I can't pick an answer or anything!
But what I did to fix it was put this
document.ontouchmove = function(e){
e.preventDefault();
}
Into its own function, just as the doTouchMove() was. Then when I wanted it to stop moving again i would just call the name of that preventDefault function.
I don't know why it makes a difference but it works! :)
本文标签:
版权声明:本文标题:javascript - How to disable, enable, then disable again scrolling in ipadiphone with e.preventDefault();? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1744213743a2086533.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论