locked
Elements disappear when using CSS transition RRS feed

  • Question

  • Hi I'm encountering this problem, When I trigger an CSS opacity transition effect on an element it causes another to disappear.


    Have a look as this code, when the event handler fires resetPasswordButton disappears, when I then mouseover where it was it re-appears.
    here's my code from my windows 8 store app:
    ----------------------------------- javascript ----------------------------------------
    app.onready = function (args){
    document.getElementById('loginButton').addEventListener("click", doAnimation);
     
    };
    function doAnimation()
    {
        var target = document.getElementById('loader');
    loader.style.opacity = "1";
    var message = document.getElementById('errorMessage');
    message.innerText = "error message";
    message.style.opacity = "1";
    }
    -------------------------------------- HTML -------------------------------------------
    <div id="Buttons">
                                    <div id="errorMessage"></div>
    <div id="loginButtons">
    <button id="loginButton" type="submit" value="submit" >LOG IN</button>
    <div id="loader">
    <progress class="win-ring"></progress>
    </div>
    <button id="resetPasswordButton" type="button">RESET PASSWORD</button>
    </div>
                                </div>
    -------------------------------------- CSS ---------------------------------------------
    #login {
        display: -ms-grid;
        -ms-grid-row: 2;
        -ms-grid-column: 2;
        -ms-grid-rows: 30px 87px 1fr;
    }
    #loginTitle {
        -ms-grid-row: 1;
    }
    #inputBoxes {
        -ms-grid-row: 2;
    }
    #inputBoxes input {
            border: 0px;
            width: 250px;
        }
    #errorMessage {
        font-size: 12px;
        margin-
        margin-bottom: 10px;
    transition: opacity 1s;
    opacity:0;
    }
    #Buttons
    {
    -ms-grid-row: 3;
    }
    #loginButtons {
        
        margin: 6.67px 0px 0px;
        display: -ms-grid;
        -ms-grid-columns: 89fr 27fr 144fr;
    -ms-grid-rows:31px 20px;
    }
    Monday, October 29, 2012 11:02 AM

Answers

  • Hi,

    I reproduce your code, and find there maybe has some problem, please check:

    <!DOCTYPE html>
    <html>
    <head>
        <title>flyout example</title>
        <!-- WinJS references -->
        <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet">
        <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
    
        <!-- ListViewExample references -->
        <script type="text/javascript" src="/buttonclick/script.js"></script>
        <style type="text/css">
            #login {
                display: -ms-grid;
                -ms-grid-row: 2;
                -ms-grid-column: 2;
                -ms-grid-rows: 30px 87px 1fr;
            }
    
    
            #loginTitle {
                -ms-grid-row: 1;
            }
    
    
            #inputBoxes {
                -ms-grid-row: 2;
            }
    
    
                #inputBoxes input {
                    border: 0px;
                    width: 250px;
                }
    
    
            #errorMessage {
                font-size: 12px;
                margin- margin-bottom: 10px;
                transition: opacity 1s;
                opacity: 0;
            }
    
    
            #Buttons {
                -ms-grid-row: 3;
            }
    
    
            #loginButtons {
                margin: 6.67px 0px 0px;
                display: -ms-grid;
                -ms-grid-columns: 89fr 27fr 144fr;
                -ms-grid-rows: 31px 20px;
            }
        </style>
    </head>
    <body>
        <div id="Buttons">
    
            <div id="errorMessage"></div>
    
            <div id="loginButtons">
    
                <button id="loginButton" type="submit" value="submit">LOG IN</button>
    
                <div id="loader">
    
                    <progress class="win-ring"></progress>
    
                </div>
    
                <button id="resetPasswordButton" type="button">RESET PASSWORD</button>
    
            </div>
    
        </div>
        </body>
    </html>
    

    (function () {
        "use strict";
    
        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
        WinJS.strictProcessing();
    
        app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                    // TODO: This application has been newly launched. Initialize
                    // your application here.
                } else {
                    // TODO: This application has been reactivated from suspension.
                    // Restore application state here.
                }
                args.setPromise(WinJS.UI.processAll().then(function completed() {
                    // addEventListener
                    document.getElementById('loginButton').addEventListener("click", doAnimation);
    
                }));
            }
        };
    
        app.oncheckpoint = function (args) {
            // TODO: This application is about to be suspended. Save any state
            // that needs to persist across suspensions here. You might use the
            // WinJS.Application.sessionState object, which is automatically
            // saved and restored across suspension. If you need to complete an
            // asynchronous operation before your application is suspended, call
            // args.setPromise().
        };
        function doAnimation() {
    
            var target = document.getElementById('loader');
    
            loader.style.opacity = "1";
    
    
            var message = document.getElementById('errorMessage');
    
            message.innerText = "error message";
    
            message.style.opacity = "1";
    
        }
        
        app.start();
    })();


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Thursday, November 1, 2012 2:29 AM
    Tuesday, October 30, 2012 3:05 AM

All replies

  • Hi,

    I reproduce your code, and find there maybe has some problem, please check:

    <!DOCTYPE html>
    <html>
    <head>
        <title>flyout example</title>
        <!-- WinJS references -->
        <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet">
        <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
    
        <!-- ListViewExample references -->
        <script type="text/javascript" src="/buttonclick/script.js"></script>
        <style type="text/css">
            #login {
                display: -ms-grid;
                -ms-grid-row: 2;
                -ms-grid-column: 2;
                -ms-grid-rows: 30px 87px 1fr;
            }
    
    
            #loginTitle {
                -ms-grid-row: 1;
            }
    
    
            #inputBoxes {
                -ms-grid-row: 2;
            }
    
    
                #inputBoxes input {
                    border: 0px;
                    width: 250px;
                }
    
    
            #errorMessage {
                font-size: 12px;
                margin- margin-bottom: 10px;
                transition: opacity 1s;
                opacity: 0;
            }
    
    
            #Buttons {
                -ms-grid-row: 3;
            }
    
    
            #loginButtons {
                margin: 6.67px 0px 0px;
                display: -ms-grid;
                -ms-grid-columns: 89fr 27fr 144fr;
                -ms-grid-rows: 31px 20px;
            }
        </style>
    </head>
    <body>
        <div id="Buttons">
    
            <div id="errorMessage"></div>
    
            <div id="loginButtons">
    
                <button id="loginButton" type="submit" value="submit">LOG IN</button>
    
                <div id="loader">
    
                    <progress class="win-ring"></progress>
    
                </div>
    
                <button id="resetPasswordButton" type="button">RESET PASSWORD</button>
    
            </div>
    
        </div>
        </body>
    </html>
    

    (function () {
        "use strict";
    
        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
        WinJS.strictProcessing();
    
        app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                    // TODO: This application has been newly launched. Initialize
                    // your application here.
                } else {
                    // TODO: This application has been reactivated from suspension.
                    // Restore application state here.
                }
                args.setPromise(WinJS.UI.processAll().then(function completed() {
                    // addEventListener
                    document.getElementById('loginButton').addEventListener("click", doAnimation);
    
                }));
            }
        };
    
        app.oncheckpoint = function (args) {
            // TODO: This application is about to be suspended. Save any state
            // that needs to persist across suspensions here. You might use the
            // WinJS.Application.sessionState object, which is automatically
            // saved and restored across suspension. If you need to complete an
            // asynchronous operation before your application is suspended, call
            // args.setPromise().
        };
        function doAnimation() {
    
            var target = document.getElementById('loader');
    
            loader.style.opacity = "1";
    
    
            var message = document.getElementById('errorMessage');
    
            message.innerText = "error message";
    
            message.style.opacity = "1";
    
        }
        
        app.start();
    })();


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Thursday, November 1, 2012 2:29 AM
    Tuesday, October 30, 2012 3:05 AM
  • Hi

    I recreated the code and for some reason it now works... strange.

    Here's the code in case you are interested:

    --------------------- style -------------------------------


    body {
        -ms-flex-align: center;
        -ms-flex-direction: column;
        -ms-flex-pack: center;
        display: -ms-flexbox;
    }

    #introContainer {
        width: 100%;
        -ms-grid-row-span: 3;
    }

    progress, refreshProgress {
        color: black !important;
    }

    #loginGrid {
        display: -ms-grid;
        height: 100%;
        -ms-grid-columns: 1fr 1fr 1fr;
        -ms-grid-rows: 1fr 280px 1fr;
        ;
        top: 0px;
        left: 0px;
        right: 0px;
        background-image: url('/images/LoginGradientBackground.jpg');
        background-position-y: 250px;
    background-repeat: no-repeat;

        background-size: contain;
    }

    button[type=submit] {
        background-color: #4577AD !important;
    }

    #top {
        -ms-grid-row: 1;
    }

    #content {
        width: 100%;
        -ms-grid-row: 2;
       
        -ms-grid-column-span: 3;
        -ms-grid-column-align: center;
        display: -ms-grid;
        -ms-grid-columns: 1fr;
        -ms-grid-rows: 1fr;
    }

    #bottom {
        background-color: #F9F9F9;
        -ms-grid-row: 3;
    }

    #contentGridDiv {
        display: -ms-grid;
        height: 100%;
        -ms-grid-columns: 240px 250px 180px 0px 0px 360px 130px;
        -ms-grid-rows: 1fr 195px 1fr;
        -ms-grid-column-align: center;
        margin-
        margin-right: auto;
    background-image: url('/images/LoginDividerLine.png');
    background-repeat: repeat-y;
    background-position-x: 600px;
    }

    #login {
        display: -ms-grid;
        -ms-grid-row: 2;
        -ms-grid-column: 2;
        -ms-grid-rows: 30px 87px 1fr;
    }

    #loginTitle {
        -ms-grid-row: 1;
    }

    #inputBoxes {
        -ms-grid-row: 2;
    }

    #inputBoxes input {
            border: 0px;
            width: 250px;
        }

     #errorMessage {
        font-size: 12px;
         margin-bottom: 10px;
        transition: opacity 1s;
        opacity: 0;
    }

    #loginButtons {
        -ms-grid-row:3;
        margin: 6.67px 0px 0px;
        display: -ms-grid;
        -ms-grid-columns: 120fr 27fr 144fr;
        -ms-grid-rows: 31px 20px;
    }

    #loader {
        color:white;
         -ms-grid-column:2;
         margin-
         margin-
        transition: opacity 1s;
        opacity: 0;
    }

    progress, refreshProgress {
        color: white !important;
    }

    #Buttons {
        -ms-grid-row: 3;
        margin: 6.67px 0px 0px;
    }

    #signUpButtons {
    -ms-grid-row: 3;
    -ms-grid-column: 1;
    margin: 8px 0px 0px;
    }

    #resetPasswordButton {
    -ms-grid-column:3;
    width: 150px;
    }

    #signUpButtons button {
    background-color: #619432;
    margin-
    }

    #Buttons button {
        background-color: #6B6B6B;
        color: black;
    }

    #forgotPass {
        -ms-grid-row: 5;
        -ms-grid-row-align: end;
    }

    #image {
        -ms-grid-row: 2;
        -ms-grid-column: 4;
    }

    #copy {
        display: -ms-grid;
        -ms-grid-columns: 1fr;
        -ms-grid-row: 2;
        -ms-grid-column: 6;
        -ms-grid-rows: 30px 95px 1fr;
    margin-
    }

    #headerText {
        -ms-grid-row: 1;
        font-size: 30px;
    }

    #copyText {
        -ms-grid-row: 2;
        font-size: 18px;
    }

    #linkText {
        -ms-grid-row: 3;
        -ms-grid-row-align: end;
    }

    ------------------- script ---------------------

    (function () {
        "use strict";

        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
        WinJS.strictProcessing();

        app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {

                } else {

                }
                args.setPromise(WinJS.UI.processAll().then(function completed() {
                    // addEventListener
                    document.getElementById('loginButton').addEventListener("click", doAnimation);

                }));
            }
        };


        function doAnimation() {
            var target = document.getElementById('loader');
            loader.style.opacity = "1";

            var message = document.getElementById('errorMessage');
            message.innerText = "error message";
            message.style.opacity = "1";
        }

        app.start();
    })();

    --------------------------------------- html -----------------------------------------

    <!DOCTYPE html>
    <html>
    <head>
        <title>flyout example</title>
        <!-- WinJS references -->
        <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet">
        <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
        <link href="css/default.css" rel="stylesheet" />
        <!-- ListViewExample references -->
        <script type="text/javascript" src="/buttonclick/script.js"></script>
        <style type="text/css">
          
        </style>
    </head>
    <body>
     <div id="loginGrid" data-win-bind="style.">
                    <div id="top"></div>
                    <div id="content">
                        <div id="contentGridDiv">
                            <div id="login">
                                <div id="inputBoxes">

                                    <input id="usernameInput"  type="email" value="claire1@22seven.com" placeholder="Enter your username..." style="height: 34px;">
                                    <input id="passwordInput" type="password" value="Manatee1" placeholder="Enter your password..." style="height: 34px;">
                                </div>
                                <div id="Buttons">
                                    <div id="errorMessage"></div>
        <!--                            <div id="Buttons">
                                        <button id="loginButton" type="submit" value="submit" style="width: 90px;">LOG IN</button>
                                        <button id="resetPasswordButton" type="button">RESET PASSWORD</button>
                                    </div>-->

                                    <div id="loginButtons">
                                        <button id="loginButton" type="submit" value="submit">LOG IN</button>
                                        <div id="loader">
                                            <progress class="win-ring"></progress>
                                        </div>
                                        <button id="resetPasswordButton" type="button">RESET PASSWORD</button>
                                    </div>
                                </div>
                            </div>
                            <div id="copy">
                                <div id="copyText">You don't need to earn more to do more. With 22seven you can see all your money in one place and in a whole new way.</div>
    <div id="signUpButtons">
    <button id="registerButton" type="button">SIGN UP</button>
    </div>
                            </div>

                        </div>
                    </div>
    <div id="logo">
    <img src="/images/LoginLogo.png"/>

    </div>
                </div>
        
        </body>
    </html>

    Wednesday, October 31, 2012 11:02 AM