White screen appears for a split second after splash screen - ionic-framework

I have made an app with IBM mobileFirst 7.0 (I also use Ionic) and I notice that right after the splash screen and for half a second or so, a white screen appears. I searched the web and some people said that uncommenting
autoHideSplash: false,
in wlInitOptions and adding this code:
var app = angular.module('app.controllers', []);
//manually hide splash screen
app.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
setTimeout(function() {
WL.App.hideSplashScreen();
}, 100);
});
})
in my controller (I only have 1) would solve the issue. Yet nothing happens. (I also changed the timeout but nothing seems to change)
I want to seee my app right after the splash screen dissappears without the white screen. How can I do that?
UPDATE & SOLUTION:
After reading Idan's answer, I made a few changes that fixed the problem.
First of all in my index.html, I was loading MobileFirst at the end of my <head>, after Ionic and all controllers had loaded. I changed that and now in the <head> tag I firstly load:
<!-- mobileFirst initialization -->
<script src="js/wlInit.js"></script>
<script src="js/messages.js"></script>
and then I load Ionic and the controllers.
I also changed the timeout of WL.App.hideSplashScreen() in my controller from 100 to 1500.
No white screen appears any longer :D

I see you're using the WL.App API, but are you sure you're using it in the right place? This API can be called only after function wlCommonInit was called.
So I think you're on the right path. It sounds like you should indeed try to extend the duration of the splash screen as something in your app is taking a while to load (hence the white flashing), so by extending the splash screen a little while longer, letting whatever it is to load, and then removing the splash screen could be a possible workaround.
Make sure this API is called only after wlCommonInit was called
Increase the duration some more.
Read more about the API, here: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.0/advanced-client-side-development/common-ui-controls/#splashscreen

You can also use ng-cloak to hide any white flashes that angular causes.

Related

Anyone implemented/used Mobile Device Screen Orientation plugin?

Has anyone successfully implemented screen orientation plugin in Sitecatalyst to capture mobile device orientation?. When we use the below code in the s_code, in the web page i am seeing some unusual behavior(ie: when we scroll the page to the bottom and then if i click anywhere on the content section, page goes to the top by default). I understand, that's happening because of this line "window.scroll(0,0)". Any help or thoughts?
Plugin Code below:
function screenOrientation(){switch(window.orientation){case 0:case 180:return("Portrait");break;case 90:case -90:return("Landscape");}window.scroll(0,0)}
Reference: [http://webanalyticsland.com/sitecatalyst-implementation/capture-mobile-device-screen-orientation-in-sitecatalyst]
Thanks in Advance.
This is clearly a code bug (or more a typo I think) and the line window.scroll(0,0) can be safely removed from the 'plugin' (its not really a plugin, just a js function that returns the orientation).
The reason this fires every time a user clicks on anywhere on the page is because you have ClickMap functionality enabled in your s_code.js configuration. This will fire an s.tl() everytime a click event occurs. the s.tl() will call the screenOrientation() function to populate your required prop/eVar.
So if you were to turn off clickMap (s.trackInlineStats=false;) this random scrolling to the top would stop even if you didn't remove the offending line. That said, remove the scrolling code, its not right or required!

Reduce initial load time - google web designer

We are developing some ads using google web designer tool
so far its good but one main issue with it is, slow loading.
its taking almost 3 seconds to load and we feel very bad about that.
can anyone know how to optimize it?
thanks.
In developing html5 banners, by default the 'polite load' is checked.
Which means you banner will not be visible and will not load until the page is loaded.
And when testing your banner, there is some moments before showing the banner to simulate the webpage load.
Why?
Because no publisher(Website) allows you to make their website slow. That is the rule. There is no way for you to force yourself to show first on a publisher website.
If you want this option. You should directly talk to the publisher/ when you get approval from them, you can uncheck 'Polite Load' when you are publishing your ad. Then your banner will show faster without any delay.
#cnu - I have experienced the same issue. The only workaround I have at the moment is to set an initial loading image - while the Ad is loading
Try adding a div with an ID of 'loading' immediately after your opening body tag.
<div id="loading" class="loading-image">
<img src="default.png"/>
</div>
Then find the following function, and set the div to block display
function handleDomContentLoaded(event) {
// This is a good place to show a loading or branding image while
// the ad loads.
document.getElementById('loading').style.display = 'block';
}
Then find the following function, and set the div to none - to hide the image after loading
function handleAdInitialized(event) {
// This marks the end of the polite load phase of the Ad. If a
// loading image was shown to the user, this is a good place to
// remove it.
document.getElementById('loading').style.display = 'none';
}
The official GWD instructions don’t match the functions actually generated in the source, which initially made this setup confusing. The code comments in the source indicate these are the correct functions to use. You can use the first frame of the Ad as the loading image, rather than a loading gif - so the user experience isn't affected too much.
Hope this helps.

How to show message during initial loading of gwt application?

I want to display a message (please wait...) or animated gif before the initial entire loading of my gwt application.
Can you give me a full example please.
Thanks
Because the GWT app is not yet loaded, you have to do it in pure HTML/CSS and/or JS in your HTML host page. The easiest is to just put it in your <body> and when the GWT app loads it starts by cleaning that "loading" message (e.g. Document.get().getElementByid("loading").removeFromParent())
Another possibility is to use code-splitting: make a first fragment that's as small as possible and will display your "loading" message, and load the rest of the app in the background. In the RunAsyncCallback, hide your "loading" message.
That said, if you feel the need to display such a "loading" message, then IMO you have a bigger problem than finding how to display it (and if you struggle to find how to display one, you're in bad shape to build an app that people will enjoy using; fortunately, this is fixable: keep learning!).

Re-rendering Facebook plugins using FB.XFBML.parse

Is there a way to use FB.XFBML.parse without rendering the a Facebook plugin again which cause it to "flicker" (disappear et reappear).
Will be using the Facebook Like button or Facebook Recommandations Bar.
Live example: http://www.gablabelle.com/eve-d
Slide to view the flickering in the lower right corner.
$.address.state(ajax_object.path).crawlable(true).value(whereiam);
$(".fb-recommendations-bar").data("href",whereiamurl);
//$(".fb-like").data("href",whereiamurl);
fburl = $(".fb-recommendations-bar").data("href");
//fburl = $(".fb-like").data("href");
console.log(fburl);
FB.XFBML.parse();
Many thanks for your help.
You can limit the scope of the re-parse by passing in the parent DOM element to FB.XFBML.parse.
Add an opacticy layer over the top of the facebook plugin div when a "page change" is needed. Animate it to fully opaque. Call the FB.XFBML.parse() and give it a few moments to re-render. Animate the layer to non-opaque, then remove the opacity layer from over the top of the facebook plugin div (or leave it there for the next time you need to do a "page change" without actually reloading the page.
This technique will give you a gracefully disappearing/reappearing plugin, rather than a jarringly harsh "flicker".
Cache the Facebook likes of the previous slide + current slide + next slide on a slide change event. So that when you go to the next or previous one and its Facebook like should already be ready/loaded, the user should not see a flickering. Unless he/she goes to fast with the slides.
I've had this recently.
I got around it by wrapping the XFMBL in a variable... don't know why but without it it seemed to flicker... a total hack of a way to stop the flickering but worked for me!!
if(call == 0){
FB.XFBML.parse();
call = 1;
}
DMCS provided what seems to be the only half-proper answer, but it's butt ugly. You don't know how long it'll take on each persons web browser to render the stuff. The callback which supposedly says it's rendered doesn't work either. Also the flicker isn't seen in firefox but only in google chrome.

Prevent cached iPhone webapp from reloading (scrolling to top)

I have an iPhone webapp that uses a cache manifest to work offline. I add the webapp to my home screen, use it (say scroll to a certain location on a page), then go back to homescreen.
When I open the app again, for a brief moment I see where I used to be (at that scrolled location on that page), but then the app "reloads" and I get scrolled to the top of the mainpage. Is there a way to prevent this "reloading"? This happens even in airplane mode (ie everything is working off the cache).
You're just seeing the default startup image, which is just a screenshot of the last place you were at. It's not "reloading"; the app wasn't loaded to begin with.
Search for "apple-touch-startup-image" to set a real loading image.
What I'm struggling with here is that the app actually seems to stay "in memory" longer if I use regular Safari as opposed to running in "apple-mobile-web-app-capable" mode. In the later case something as simple as pressing the home button, then task-switching back to the app causes a reload. Doing the same thing just in Safari often does not reload. So I'm worse off by using "apple-mobile-web-app-capable".
I don't believe there is a real 'reload' event. onload and onunload are all we get.
the onload handler starts up as if it is your first time coming to the page.
the onunload handler is the key to clearing out old content.
I like to provide alternate content for people who are coming back to my web app.
window.onunload=function(){
document.getElementsByTagName('body')[0].className+=' unloading'
}
And let the CSS do the dirty work to hide most of the body and show alternate content.
(this answer does not rely on jQuery or other frameworks)
// on load
window.scroll(0,0);
To ensure no old content is displayed while launching I use this in my page:
window.addEventListener('unload', function() { $('body').hide(); } );
Thus the last state of the page is empty and is what is shown to the user when the page is opened again.