简体   繁体   English

禁用Cordova / PhoneGap上的所有用户输入事件

[英]Disable all user input events on Cordova/PhoneGap

I would like to temporary disable all touch/virtual keyboard events in a hybrid Cordova/PhoneGap app. 我想暂时禁用混合Cordova / PhoneGap应用程序中的所有触摸/虚拟键盘事件。 Is there some kind of plug-in to achieve this natively? 是否有某种插件可以原生实现此目的? Perhaps something, that disables the whole web view from any user input. 也许是什么使任何用户输入都无法使用整个Web视图。 If there isn't one, how can this be achieved with javascript/CSS/HTML? 如果没有,那么如何使用javascript / CSS / HTML实现呢?

PS I need this feature in order to make sure the user won't disturb the predefined animated scenario. PS我需要此功能,以确保用户不会打扰预定义的动画场景。

You can use javascript or a overlay to handle this. 您可以使用javascript或叠加层来处理此问题。

Using javascript 使用JavaScript

var handler = document.addEventListener('click, touchEnd, touchStart, touch, keypress', function (evt) {
  evt.stopPropagation();
  evt.preventDefault();
});

Once your animation is complete use below to remove blocker; 动画制作完成后,请使用下面的方法删除障碍物;

handler.removeEventListener();

Or create a div with css 或使用CSS创建div

.overlay {
  width: 100%;
  height: 100%;
  display: block;
  z-index: 999999;
  position: absolute;
  top: 0;
  left: 0;
}

Once your animation is complete you can hide the div or remove it. 动画制作完成后,您可以隐藏div或将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM