Files
meteor/packages/launch-screen/mobile-launch-screen.js
Martijn Walraven 3358369318 Fix bug in launch-screen that disabled holding it beyond a 6s timeout
The default behavior meant that the launch screen would always be
released twice on a single hold: once when the template is rendered,
and once after a 6s timeout. So additional holds would not have any
effect beyond that timeout.
2016-03-27 13:52:29 +02:00

43 lines
920 B
JavaScript

// XXX This currently implements loading screens for mobile apps only,
// but in the future can be expanded to all apps.
var holdCount = 0;
var alreadyHidden = false;
LaunchScreen = {
hold: function () {
if (! Meteor.isCordova) {
return {
release: function () { /* noop */ }
};
}
if (alreadyHidden) {
throw new Error("Can't show launch screen once it's hidden");
}
holdCount++;
var released = false;
var release = function () {
if (! Meteor.isCordova)
return;
if (! released) {
released = true;
holdCount--;
if (holdCount === 0 &&
typeof navigator !== 'undefined' && navigator.splashscreen) {
alreadyHidden = true;
navigator.splashscreen.hide();
}
}
};
// Returns a launch screen handle with a release method
return {
release: release
};
}
};