当添加到 iPhone 上的主屏幕时,这个 Angular 2 应用程序的响应速度比在 Safari 中运行时的响应速度要慢。
我通过将其添加到 index.html 使其具有 Web 应用程序功能:
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="Angular NavTabs">
如果你有几分钟时间,在 Github 页面上查看 https://cmermingas.github.io/angular-tab-nav/.
在 Safari 中运行时,选项卡之间的切换感觉非常灵敏。然而,当应用程序从主屏幕启动时,感觉有点滞后。
我可以在代码中更改或添加一些内容来修复此行为吗?
注意:如果我从应用程序中删除动画,也会发生同样的情况。
我录制了几个动画 GIF 来尝试展示差异,但除非您实际与应用程序交互,否则很难欣赏。
你正在经历臭名昭著的“300ms秒延迟 http://www.telerik.com/blogs/what-exactly-is.....-the-300ms-click-delay”,该问题在 Safari Mobile 中已修复相当长一段时间,但一旦您的应用程序添加到主屏幕,该问题仍然存在。
使用快速点击 https://github.com/ftlabs/fastclick图书馆应该可以解决这个问题。
要在 Angular 应用程序中使用它,请安装 npm 包:
npm install --save fastclick
然后将其添加到您的main.ts
file:
import * as fastClick from 'fastclick';
fastClick.attach(document.body);
Edit:
在 iOS 11 中,添加到主屏幕的 Web 应用程序现在将托管在 WKWebView 而不是 WebView 中,这将废弃 FastClick:https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Safari_11_0/Safari_11_0.html https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Safari_11_0/Safari_11_0.html
希望能帮助到你。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)