codecamp

Apache Cordova 避免300 ms点击延迟

避免300 ms点击延迟

步骤

1、在你的iOS设备或iOS模拟器上测试该应用程序:点击Help按钮,并留意弹出对话框之前的延迟。

这个延迟的发生时由于操作系统要大约等待300 ms以确认用户是否要再次点击目标(并因此执行一个双击事件)。

2、在index.html中,添加以下脚本标记:

<script src="https://atts.w3cschool.cn/attachments/image/wk/apachecordovatutorial/fastclick.js"></script>

FastClick是由金融时报创建的开源库。更多信息请点击这里。

3、在app.js中,在deviceready事件处理器中注册FastClick。

FastClick.attach(document.body);

4、测试应用程序:点击Help按钮。现在对话框会没有延迟地出现。

Apache Cordova 使用本地通知
Apache Cordova 设置单页应用程序
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }