贝塞尔曲线动画在线模拟

802 阅读1分钟
原文链接: xuanfengge.com

Ceaser CSS Easing Animation Tool

  1. Choose an easing type and test it out with a few effects.
  2. If you don’t quite like the easing, grab a handle and fix it.
  3. When you’re happy, snag your code and off you go.

Now that we can use CSS transitions in all the modern browsers, let’s make them pretty. I love the classic Penner equations with Flash and jQuery, so I included most of those. If you’re anything like me*, you probably thought this about the default easing options: “ease-in, ease-out...yawn.” The mysterious cubic-bezier has a lot of potential, but was cumbersome to use. Until now. Also, touch-device friendly!

*If you are anything like me, we should be friends @matthewlein

Note: Bugfixes have landed, so the newest Webkit now supports values above 1 and below 0. For the time being, I am including fallback code for older Webkit that is clamped between 0 and 1 when needed.

Code snippets, short and long-hand:

-webkit-transition: all 500ms cubic-bezier(0.250, 0.250, 0.750, 0.750);
   -moz-transition: all 500ms cubic-bezier(0.250, 0.250, 0.750, 0.750);
     -o-transition: all 500ms cubic-bezier(0.250, 0.250, 0.750, 0.750);
        transition: all 500ms cubic-bezier(0.250, 0.250, 0.750, 0.750); /* linear */

-webkit-transition-timing-function: cubic-bezier(0.250, 0.250, 0.750, 0.750);
   -moz-transition-timing-function: cubic-bezier(0.250, 0.250, 0.750, 0.750);
     -o-transition-timing-function: cubic-bezier(0.250, 0.250, 0.750, 0.750);
        transition-timing-function: cubic-bezier(0.250, 0.250, 0.750, 0.750); /* linear */

If this saves you time, or blows your mind, consider making a donation to keep these projects alive.

Resources

Webkit/Safari/Chrome desicion-makers: Hoping Bug 45761 gets fixed/implemented soon so I can add easeBack effects.

Let the good times roll!