문제

I have a WinJS app with a splash screen as we know it last certain time, lets suppose three seconds, what do I have to do for make it to last five seconds instead???


EDIT: Going to share my code

.HTML: just added this code to my and hide my content div or main div(s) by adding "hidden" property

header

<script src="js/extendedSplash.js"></script>

body

<!--        SPLASH SCREEN DIV-->
    <div id="extendedSplashScreen" class="extendedSplashScreen hidden">
        <img id="extendedSplashImage" src="images/splashscreen.png" alt="Splash screen image" />
            <progress id="extendedSplashProgress" style="color: white;" class="win-medium win-ring"></progress>
    </div>
<!--        END SPLASH SCREEN DIV-->

.CSS file: add next code to your stylesheet file

/*SPLASH SCREEN FORMAT*/
.extendedSplashScreen {
    background-color:#ea0000;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0px;
    left: 0px;
    text-align: center;
}

.extendedSplashScreen.hidden {
    display: none;
}

#extendedSplashImage {
    position: absolute;
}

#extendedSplashDescription
{
    position: absolute;
    width: 100%;
    top: calc(100% - 140px);
    text-align: center;
}

#extendedSplashText
{
    font-family: 'Segoe UI Semilight';
    font-size: 11pt;
    text-align: center;
    width: 75%;
    color: #ffffff;
}
/*END SPLASH SCREEN FORMAT*/

.JS File(s) create a JS file (extendedSplash.js)

(function () {
    "use strict";
    var splash      = null;  // Variable to hold the splash screen object.
    var dismissed   = false; // Variable to track splash screen dismissal status.
    var coordinates = { x: 0, y: 0, width: 0, height: 0 }; // Object to store splash screen image coordinates. It will be initialized during activation.

    function loadSplashScreen(args) {
        // Retrieve splash screen object
        splash = args.detail.splashScreen;

        // Listen for window resize events to reposition the extended splash screen image accordingly.
        // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...
        window.addEventListener("resize", onResize, false);

        // Retrieve the window coordinates of the splash screen image.
        coordinates = splash.imageLocation;

        // Register an event handler to be executed when the splash screen has been dismissed.
        splash.addEventListener("dismissed", onSplashScreenDismissed, false);

        // Create and display the extended splash screen using the splash screen object.
        show(splash);

        // Listen for window resize events to reposition the extended splash screen image accordingly.
        // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...
        window.addEventListener("resize", onResize, false);
    }


    // Displays the extended splash screen. Pass the splash screen object retrieved during activation.
    function show(splash) {
        var extendedSplashImage = document.getElementById("extendedSplashImage");

        // Position the extended splash screen image in the same location as the system splash screen image.
        extendedSplashImage.style.top       = splash.imageLocation.y        + "px";
        extendedSplashImage.style.left      = splash.imageLocation.x        + "px";
        extendedSplashImage.style.height    = splash.imageLocation.height   + "px";
        extendedSplashImage.style.width     = splash.imageLocation.width    + "px";

        // Position the extended splash screen's progress ring. Note: In this sample, the progress ring is not used.
        /*
        var extendedSplashProgress = document.getElementById("extendedSplashProgress");
        extendedSplashProgress.style.marginTop = splash.imageLocation.y + splash.imageLocation.height + 32 + "px";
        */

        // Once the extended splash screen is setup, apply the CSS style that will make the extended splash screen visible.
        var extendedSplashScreen = document.getElementById("extendedSplashScreen");
        WinJS.Utilities.removeClass(extendedSplashScreen, "hidden");
    }

    // Updates the location of the extended splash screen image. Should be used to respond to window size changes.
    function updateImageLocation(splash) {
        if (isVisible()) {
            var extendedSplashImage = document.getElementById("extendedSplashImage");

            // Position the extended splash screen image in the same location as the system splash screen image.
            extendedSplashImage.style.top       = splash.imageLocation.y        + "px";
            extendedSplashImage.style.left      = splash.imageLocation.x        + "px";
            extendedSplashImage.style.height    = splash.imageLocation.height   + "px";
            extendedSplashImage.style.width     = splash.imageLocation.width    + "px";

            // Position the extended splash screen's progress ring. Note: In this sample, the progress ring is not used.
            /*
            var extendedSplashProgress = document.getElementById("extendedSplashProgress");
            extendedSplashProgress.style.marginTop = splash.imageLocation.y + splash.imageLocation.height + 32 + "px";
            */
        }
    }

    // Checks whether the extended splash screen is visible and returns a boolean.
    function isVisible() {
        var extendedSplashScreen = document.getElementById("extendedSplashScreen");
        return !(WinJS.Utilities.hasClass(extendedSplashScreen, "hidden"));
    }

    // Removes the extended splash screen if it is currently visible.
    function remove() {
        if (isVisible()) {
            var extendedSplashScreen = document.getElementById("extendedSplashScreen");
            WinJS.Utilities.addClass(extendedSplashScreen, "hidden");
        }
    }

    function onResize() {
        // Safely update the extended splash screen image coordinates. This function will be fired in response to snapping, unsnapping, rotation, etc...
        if (splash) {
            // Update the coordinates of the splash screen image.
            coordinates = splash.imageLocation;
            updateImageLocation(splash);
        }
    }

    function onSplashScreenDismissed() {
        // Include code to be executed when the system has transitioned from the splash screen to the extended splash screen (application's first view).
        dismissed = true;

        // Tear down the app's extended splash screen after completing setup operations here...
        // In this sample, the extended splash screen is torn down when the "Learn More" button is clicked.
        //document.getElementById("learnMore").addEventListener("click", ExtendedSplash.remove, false);
    }

    //namespace created for accessing to certain methods created inside this JS file from external JS
    WinJS.Namespace.define("ExtendedSplash", {
        isVisible:          isVisible,
        remove:             remove,
        loadSplashScreen:   loadSplashScreen
    });
})();

in your default.js look for the function or the section with

args.detail.kind === activation.ActivationKind.launch

and there add this

    app.onactivated = function (args) {
        if (args.detail.kind === activation.ActivationKind.launch) {
            ExtendedSplash.loadSplashScreen(args);                                  //loads extended splash screen

            // Use setPromise to indicate to the system that the splash screen must not be torn down
            // until after processAll and navigate complete asynchronously.
            args.setPromise(WinJS.UI.processAll().then(function(){
                setTimeout(function () {
                    ExtendedSplash.remove();                                        //removes splash screen
                    document.getElementById("content").removeAttribute("hidden");   //shows main screen (content and footer)
                    document.getElementById("footer").removeAttribute("hidden");
                }, 4000);
            }));

}

in my case I added a delay of 4 seconds and then I hide my splashScreen

ExtendedSplash.remove();

and then I showed my two main Divs (content and footer)

document.getElementById("content").removeAttribute("hidden");
//shows main screen (content and footer) document.getElementById("footer").removeAttribute("hidden");

도움이 되었습니까?

해결책

It's quite easy ... You'll just create a page that you show first when the splash is taken down that looks just like your splash screen.

It's fully documented here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top