HTML | DOM Style transitionTimingFunction property

The DOM Style transitionTimingFunction property allows a transition effect to change speed over its duration. Transition effect provides a way to control animation speed when changing properties.

Syntax:

  • To set the property:
    object.style.transitionTimingFunction = "ease|linear|ease-in|
    ease-out|ease-in-out"
  • To get the property:
    object.style.transitionTimingFunction
  • Property Values:

    • ease: Specifies a transition effect that starts slowly, then fast, then slow.
    • linear: Specifies a transition effect with the same speed from start to end.
    • ease-in: Specifies a transition effect with a slow start.
    • ease-out: Specifies a transition effect with a slow end.
    • ease-in-out: Specifies a transition effect with a slow start and end.

    Example 1: This example describes linear property value.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
          
    <head
        <title>
            HTML | DOM Style transitionTimingFunction property
        </title>
        <style
          
            #GFG {
              background-color: green;
              width: 150px;
              height: 150px;
              overflow: auto;
                
              /* For Safari Browser */
              -webkit-transition: all 2s;
              transition: all 2s;
            }
              
            #GFG:hover {
              width: 300px;
              height: 300px;
            }
        </style>
    </head>
      
    <body>
          
        <button onclick = "myGeeks()">
            Click Here!
        </button>
          
        <br><br>
          
        <div id = "GFG">
        </div>
          
        <script>
        function myGeeks() {
              
            /* For Safari Browser */
            document.getElementById("GFG").style.WebkitTransitionTimingFunction
                    = "linear";
            document.getElementById("GFG").style.transitionTimingFunction
                    = "linear"; 
        }
        </script>
      
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Example 2: This example describes ease-in property value.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
          
    <head>
        <title>
            HTML | DOM Style transitionTimingFunction property
        </title>
        <style
          
            #GFG {
              background-color: green;
              width: 150px;
              height: 150px;
              overflow: auto;
                
              /* For Safari Browser */
              -webkit-transition: all 2s;
              transition: all 2s;
            }
              
            #GFG:hover {
              width: 300px;
              height: 300px;
            }
        </style>
    </head>
      
    <body>
          
        <button onclick = "myGeeks()">
            Click Here!
        </button>
          
        <br><br>
          
        <div id = "GFG">
        </div>
          
        <script>
        function myGeeks() {
              
            /* For Safari Browser */
            document.getElementById("GFG").style.WebkitTransitionTimingFunction
                    = "ease-in";
            document.getElementById("GFG").style.transitionTimingFunction
                    = "ease-in"; 
        }
        </script>
      
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Note: Use WebkitTransitionTimingFunction as a keyword in safari browser.

    Supported Browsers: The browser supported by HTML | DOM Style transitionTimingFunction property are lited below:

    • Google Chrome 26.0
    • Internet Explorer 10.0
    • Mozilla Firefox 16.0
    • Opera 12.1
    • Safari 6.1, 3.1 WebkitTransitionTimingFunction


    My Personal Notes arrow_drop_up

    Check out this Author's contributed articles.

    If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




    Article Tags :
    Practice Tags :


    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.