Skip to content

Instantly share code, notes, and snippets.

@bigsergey
Last active May 13, 2016 12:40
Show Gist options
  • Select an option

  • Save bigsergey/6779fee24494a0f6b2241821d16b2348 to your computer and use it in GitHub Desktop.

Select an option

Save bigsergey/6779fee24494a0f6b2241821d16b2348 to your computer and use it in GitHub Desktop.

Revisions

  1. bigsergey revised this gist May 13, 2016. 1 changed file with 24 additions and 0 deletions.
    24 changes: 24 additions & 0 deletions CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,30 @@ How it works:
    ![image](http://www.phpied.com/files/reflow/render.png 'Source: Rendering: repaint, reflow/relayout, restyle')

    *Source: [Rendering: repaint, reflow/relayout, restyle](http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/)*

    Define css animation:
    ```
    @keyframes myAnimation {
    0% {
    opacity: 0;
    transform: translate(0, 0);
    }
    30% {
    opacity: 1;
    transform: translate(0, 0);
    }
    60% {
    transform: translate(100px, 0);
    }
    100% {
    transform: translate(100px, 100px);
    }
    }
    #box {
    animation: myAnimation 2.75s;
    }
    ```

    ## TIPS
    Be careful of animating properties that change the dimensions of or position of objects on your page (also known as causing a reflow). These can be especially slow, depending on the browser.

  2. bigsergey revised this gist May 13, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    How it works:

    ![image](http://www.phpied.com/files/reflow/render.png 'Source: Rendering: repaint, reflow/relayout, restyle')

    *Source: [Rendering: repaint, reflow/relayout, restyle](http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/)*
    ## TIPS
    Be careful of animating properties that change the dimensions of or position of objects on your page (also known as causing a reflow). These can be especially slow, depending on the browser.
  3. bigsergey revised this gist May 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    How it works:

    ![image](http://www.phpied.com/files/reflow/render.png 'Source: Rendering: repaint, reflow/relayout, restyle')

    *Source: [Rendering: repaint, reflow/relayout, restyle](http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/)*
    ## TIPS
    Be careful of animating properties that change the dimensions of or position of objects on your page (also known as causing a reflow). These can be especially slow, depending on the browser.

  4. bigsergey revised this gist May 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    How it works:

    [image](http://www.phpied.com/files/reflow/render.png)
    ![image](http://www.phpied.com/files/reflow/render.png 'Source: Rendering: repaint, reflow/relayout, restyle')

    ## TIPS
    Be careful of animating properties that change the dimensions of or position of objects on your page (also known as causing a reflow). These can be especially slow, depending on the browser.
  5. bigsergey revised this gist May 13, 2016. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    # CSS Animations

    How it works:

    [image](http://www.phpied.com/files/reflow/render.png)

    ## TIPS
    Be careful of animating properties that change the dimensions of or position of objects on your page (also known as causing a reflow). These can be especially slow, depending on the browser.

  6. bigsergey revised this gist May 13, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -40,6 +40,9 @@ e.css('height', '100px');
    }
    ```

    **First read values then set new values.**


    ## Useful links:
    - [Rendering: repaint, reflow/relayout, restyle](http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/)
    - [Myth Busting: CSS Animations vs. JavaScript](https://css-tricks.com/myth-busting-css-animations-vs-javascript/)
  7. bigsergey revised this gist May 13, 2016. 1 changed file with 33 additions and 1 deletion.
    34 changes: 33 additions & 1 deletion CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,38 @@ Be careful of animating properties that change the dimensions of or position of

    Instead use the transform property and the translate(), translateX(), and translateY() function.

    ### Code examples
    Bad:
    ```
    function test() {
    var e = $('#test');
    var width = e.css('width');
    if (width == '50px')
    e.css('width', '100px');
    var height = e.css('height');
    if (height == '50px')
    e.css('height', '100px');
    }
    ```
    ```e.css()``` fires ```window.getComputedStyle()``` and then *reflow*.

    Good:
    ```
    function test() {
    var e = $('#test');
    var width = e.css('width'),
    height = e.css('height');
    if (width == '50px')
    e.css('width', '100px');
    if (height == '50px')
    e.css('height', '100px');
    }
    ```

    ## Useful links:
    - [Rendering: repaint, reflow/relayout, restyle](http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/)
    - [Myth Busting: CSS Animations vs. JavaScript](https://css-tricks.com/myth-busting-css-animations-vs-javascript/)
    - [Myth Busting: CSS Animations vs. JavaScript](https://css-tricks.com/myth-busting-css-animations-vs-javascript/)
    - [REFLOWS & REPAINTS: CSS PERFORMANCE MAKING YOUR JAVASCRIPT SLOW?](http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/)
  8. bigsergey revised this gist May 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## TIP
    ## TIPS
    Be careful of animating properties that change the dimensions of or position of objects on your page (also known as causing a reflow). These can be especially slow, depending on the browser.

    * top
  9. bigsergey revised this gist May 13, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,5 @@ Be careful of animating properties that change the dimensions of or position of
    Instead use the transform property and the translate(), translateX(), and translateY() function.

    ## Useful links:
    - [Rendering: repaint, reflow/relayout, restyle](http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/)
    - [Rendering: repaint, reflow/relayout, restyle](http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/)
    - [Myth Busting: CSS Animations vs. JavaScript](https://css-tricks.com/myth-busting-css-animations-vs-javascript/)
  10. bigsergey revised this gist May 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,4 @@ Be careful of animating properties that change the dimensions of or position of
    Instead use the transform property and the translate(), translateX(), and translateY() function.

    ## Useful links:
    - (Rendering: repaint, reflow/relayout, restyle)[http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/]
    - [Rendering: repaint, reflow/relayout, restyle](http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/)
  11. bigsergey revised this gist May 13, 2016. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -7,4 +7,7 @@ Be careful of animating properties that change the dimensions of or position of
    * bottom
    * margin-*

    Instead use the transform property and the translate(), translateX(), and translateY() function
    Instead use the transform property and the translate(), translateX(), and translateY() function.

    ## Useful links:
    - (Rendering: repaint, reflow/relayout, restyle)[http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/]
  12. bigsergey revised this gist May 13, 2016. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,10 @@
    ## TIP
    Be careful of animating properties that change the dimensions of or position of objects on your page (also known as causing a reflow). These can be especially slow, depending on the browser.

    top
    left
    right
    bottom
    margin-*
    * top
    * left
    * right
    * bottom
    * margin-*

    Instead use the transform property and the translate(), translateX(), and translateY() function
  13. bigsergey created this gist May 13, 2016.
    9 changes: 9 additions & 0 deletions CSSAnimations.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    ## TIP
    Be careful of animating properties that change the dimensions of or position of objects on your page (also known as causing a reflow). These can be especially slow, depending on the browser.

    top
    left
    right
    bottom
    margin-*
    Instead use the transform property and the translate(), translateX(), and translateY() function