cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daserge <...@git.apache.org>
Subject [GitHub] cordova-plugin-splashscreen issue #107: Browser platform brought closer to i...
Date Thu, 30 Jun 2016 15:17:08 GMT
Github user daserge commented on the issue:

    https://github.com/apache/cordova-plugin-splashscreen/pull/107
  
    @petermetz, thanks for your contribution!
    The code looks good to me, although there is an issue that the splashscreen does not hide
on server cold-start sometimes:
    ```javascript
    // index.js
    onDeviceReady: function() {
        app.receivedEvent('deviceready');
    
        navigator.splashscreen.hide();
    },
    ```
    It could be caused by the async nature of `initAndShow` which needs to retrieve and apply
config.xml so that `hide` is called before `show`.
    
    Proper solution could be to make the Browser platform wait for the splashscreen plugin
init.
    
    A workaround could be like this:
    ```javascript
        show: function () {
            if(!localSplash) {
                window.addEventListener("resize", onResize, false);
                localSplash = document.createElement("div");
                localSplash.style.backgroundColor = bgColor;
                localSplash.style.position = "absolute";
                localSplash.style["z-index"] = "99999";
    
                localSplashImage = document.createElement("img");
                localSplashImage.src = imageSrc;
                localSplashImage.style.position = "absolute";
    
                updateImageLocation();
    
                localSplash.appendChild(localSplashImage);
                document.body.appendChild(localSplash);
    
                // deviceready fires earlier than the plugin init on cold-start
                if (shouldHideImmediately) {
                    shouldHideImmediately = false;
                    window.setTimeout(function () {
                        SplashScreen.hide();
                    }, 1000);
                }
            }
        },
        hide: function () {
            if(localSplash) {
                var innerLocalSplash = localSplash;
                localSplash = null;
                window.removeEventListener("resize", onResize, false);
    
                innerLocalSplash.style.opacity = '0';
                innerLocalSplash.style["-webkit-transition"] = "opacity 1s ease-in-out";
                innerLocalSplash.style["-moz-transition"] = "opacity 1s ease-in-out";
                innerLocalSplash.style["-ms-transition"] = "opacity 1s ease-in-out";
                innerLocalSplash.style["-o-transition"] = "opacity 1s ease-in-out";
    
                window.setTimeout(function () {
                    document.body.removeChild(innerLocalSplash);
                    innerLocalSplash = null;
                }, 1000);
            } else {
                shouldHideImmediately = true;
            }
        }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message