[英]AngularJS/Cordova/Phonegap Ipad 3 and Iphone 4s not fast enough?
I own an AngularJS app (angular v1.2.19) that I converted into iOS app using Cordova/PhoneGap. 我拥有一个AngularJS应用程序(Angular v1.2.19),并使用Cordova / PhoneGap将其转换为iOS应用程序。
However, it seems that the resolve
property (see below) is taking into account but the associated page is displayed BEFORE the promise is resolved, leading to some ugly flickering. 但是,似乎已经考虑了
resolve
属性(请参见下文),但是在解决诺言之前显示了关联的页面,这导致了一些丑陋的闪烁。
Flickering in this case is: the form only displays fieldset and legend + buttons for 1 second, and then the whole data (input etc..) are displayed. 在这种情况下,闪烁是: 表单仅显示fieldset和Legend +按钮1秒钟,然后显示整个数据(输入等)。
$routeProvider
.when('/page/meetings/123/edit',
{
templateUrl: "edit.html",
controller: "EditCtrl"
resolve: {
activities: ['Activities', function (Activities) {
return Activities.getList().then(function(response) {
return response.data;
});
}]
}
}
}
)
//page is displayed before activities are fully loaded.
Does a known bug regarding resolve
property exist with Cordova? Cordova是否存在有关
resolve
属性的已知错误? Or a configuration I should add? 还是我应该添加的配置?
It works well in a browser , but in the iOS app, I don't manage to make Angular resolve the promise before the page is rendered. 它在浏览器中运行良好 ,但是在iOS应用中,我无法使Angular在呈现页面之前解决承诺。
I don't figure out why this only occurs with iOS app and not web browser. 我不知道为什么这仅发生在iOS应用程序而不是Web浏览器中。
When I remove the resolve
section, the page displays without flickering, although I don't have activities populated. 当我删除“
resolve
部分时,尽管我没有填写任何活动,但页面不会闪烁显示。
Maybe just a performance reason? 也许只是性能原因? Indeed, I tested the path
/page/meetings/123/edit
in my Ipad 3 (named "new Ipad") from a page where there isn't a lot of content, and it shows the page AFTER promises are resolved => fine. 确实,我在内容不多的页面上测试了Ipad 3(名为“新Ipad”)中的路径
/page/meetings/123/edit
,该页面显示了承诺被解决后的页面=>很好。
The strange thing is that when I put the same link on a heavy page..listing several items, the targeted page (edit page) still flickers, displaying no form for about 1 second and then displays the whole. 奇怪的是,当我将同一个链接放在沉重的页面上..列出多个项目时,目标页面(编辑页面)仍然闪烁,大约一秒钟不显示任何表格,然后显示整个页面。
To make things more strange, the exact same code on Iphone 4s involve flickers no matter where is the /page/meetings/123/edit
link (heavy or light page). 为了使事情更加奇怪,无论
/page/meetings/123/edit
链接在何处(重载页面或浅色页面),Iphone 4s上完全相同的代码都包含闪烁。
On the contrary, web mobile version (Safari) on the iPhone 4s and Ipad is perfect. 相反,iPhone 4s和Ipad上的网络移动版本(Safari)非常完美。 Really don't figure out why.
真的不知道为什么。
After some...hours of search, I found the reason. 经过数小时的搜索,我找到了原因。
In the edit page's controller, I initially did this: 在编辑页面的控制器中,我最初是这样做的:
$anchorScroll(); //scrolling to the top
It seems that it conflicts with the display of elements. 似乎与元素的显示冲突。
That explains why when I come from a page that needed scrolling (like 20 items in the list page), the conflict appears. 这就解释了为什么当我来自需要滚动的页面(例如列表页面中的20个项目)时,会出现冲突。
So the solution I choose is to do this, in order to delay the scrolling with the most minimal amount of time: 因此,我选择的解决方案是执行此操作,以便以最短的时间延迟滚动:
$timeout(
function(){
$anchorScroll();
},
0);
The whole now works well with PhoneGap/Cordova for iOS app. 现在,整体可与适用于iOS应用程序的PhoneGap / Cordova完美配合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.