๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸŒŒ | WEB DEV/HTML CSS

CSS _transition(2) (timing-function)

by KASSID 2022. 1. 14.

๋ชฉ์ฐจ

    728x90

    ์ €๋ฒˆ์— ์ด์–ด์„œ transition ๋‘ ๋ฒˆ์งธ timing-function์„ ์•Œ์•„๋ณด์•˜๋‹ค.

     

     timing-function 

    ์ „ํ™˜ํšจ๊ณผ์˜ ์‹œ๊ฐ„๋‹น ์†๋„๋ฅผ ์กฐ์ •ํ•œ๋‹ค.

     

    ๊ฐ’์˜ ์ข…๋ฅ˜

    1. ease : ๊ธฐ๋ณธ๊ฐ’ / ์ ์  ์†๋„๊ฐ€ ์ฆ๊ฐ€ํ•˜๋‹ค๊ฐ€ ๋Š๋ ค์ง

    2. linear : ๋˜‘๊ฐ™์€ ์†๋„๋กœ ๋๊นŒ์ง€

    3. ease-in : ์ฒœ์ฒœํžˆ ์‹œ์ž‘ํ•˜์—ฌ ๋๋‚ ๋•Œ๊นŒ์ง€ ๋นจ๋ผ์ง

    4. ease-out : ๋น ๋ฅด๊ฒŒ ์‹œ์ž‘ํ•ด์„œ ๋Š๋ ค์ง€๋ฉฐ ๋

    5. ease-in-out : ์ฒœ์ฒœํžˆ ์‹œ์ž‘ํ•ด์„œ ๋นจ๋ผ์กŒ๋‹ค๊ฐ€ ๋‹ค์‹œ ๋Š๋ ค์ง

    6. steps(๋‹จ๊ณ„ ์ˆ˜, jump-term)

    7. step-start : steps(1, start)์™€ ๋™์ผ

    8. step-end : steps(1, end)์™€ ๋™์ผ

    9. cubic-bezier(p1, p2, p3, p4) : ๋ฒ ์ง€์–ด ๊ณก์„ 


    1~5๊นŒ์ง€ ๋ชจ๋‘ ๋ฒ ์ง€์–ด ๊ณก์„ ์œผ๋กœ ํ‘œํ˜„์ด ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ

    ๊ทธ๋ž˜ํ”„๋กœ ํ‘œํ˜„์„ ํ•ด๋ณด๋ฉด

    (https://cubic-bezier.com)

     

    ์ง„ํ–‰-์‹œ๊ฐ„ ๊ทธ๋ž˜ํ”„

     

    1. ease = cubic-bezier(0.25, 0.1, 0.25, 1.0)

    2. linear = cubic-bezier(0.0, 0.0, 1.0, 1.0)

    3. ease-in = cubic-bezier(0.42, 0, 1.0, 1.0)

    4. ease-out = cubic-bezier(0, 0, 0.58, 1.0)

    5. ease-in-out = cubic-bezier(0.42, 0, 0.58, 1.0)


     steps 

    steps๋Š” ๋ณ€ํ™” ๋‹จ๊ณ„ ์ˆ˜์™€ jump-term์„ ๊ฐ’์œผ๋กœ ๋ฐ›๋Š”๋‹ค.

     

    jump-term์˜ ์ข…๋ฅ˜

    (jump-start, jump-end, both, none)

    ์ด๋•Œ ์•ž์˜ 2๊ฐœ๋Š” start์™€ end๋กœ ์ถ•์•ฝํ•ด์„œ ์“ธ ์ˆ˜ ์žˆ๋‹ค.

     

    ์ด๋Š” ๋งŒ์•ฝ ๋‹จ๊ณ„ ์ˆ˜๊ฐ€ '5'๋ผ๋ฉด

    ๋ณ€ํ™”๊ฐ€ ์ผ์‹œ์ •์ง€ํ•˜๋Š” ๋ถ€๋ถ„์˜ ์ข…๋ฅ˜๊ฐ€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

    (0 ~ 100)

     

    1. 0 20 40 60 80 (jump-start/start)

    2. 20 40 60 80 100 (jump-end/end)

    3. 0 25 50 75 100 (jump-both)

     

    o-o-o-o-o-

    -o-o-o-o-o

    o-o-o-o-o

     

     

     step-start & step-end 

    steps(1, start) / steps(1, end) ์™€ ๊ฐ™๋‹ค.

     

     

    ์˜ˆ์‹œ)

    div {
        background: blueviolet;
        transition-property: width, height, opacity;
        transition-duration: 1s;
        transition-delay: 0s, 1s, 1s;
        transition-timing-function: steps(2, start);
    }
    
    div:hover {
        width: 200px;
        height: 200px;
        opacity: 0.5;
    }

     

    ์ถœ์ฒ˜ : MDN(https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function)

    ๋Œ“๊ธ€