前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Css3 Animation 动画原则二

Css3 Animation 动画原则二

作者头像
grain先森
发布2019-03-28 17:23:21
3880
发布2019-03-28 17:23:21
举报
文章被收录于专栏:grain先森

预备动作 (Anticipation)

预备动作

运动不倾向于突然发生。在现实生活中,无论是一个球在掉到桌子前就开始滚动,或是一个人屈膝准备起跳,运动通常有着某种事先的累积。

我们能用它去让我们的过渡动画显得更逼真。预备动作可以是一个细微的反弹,帮人们理解什么对象将在屏幕中发生变化并留下痕迹。

例如,悬停在一个元件上时可以在它变大前稍微缩小,在初始列表中添加额外的条目来介绍其它条目的移除方法。

HTML
代码语言:javascript
复制
<h1>Principle 2: Anticipation</h1>
<h2><a href="https://cssanimation.rocks/principles/" target="_parent">Animation Principles for the Web</h2>
<article class="principle two">
   <div class="shape"></div>
   <div class="surface"></div>
</article>
CSS
代码语言:javascript
复制
.two .shape {
 animation: two 5s infinite ease-out;
 transform-origin: 50% 7em;
}

.two .surface {
 background: #000;
 width: 8em;
 height: 1em;
 position: absolute;
 top: calc(50% + 4em);
 left: calc(50% - 3em);
}

@keyframes two {
 0%, 15% {
   opacity: 0;
   transform: none;
 }
 15%, 25% {
   opacity: 1;
   transform: none;
   animation-timing-function: cubic-bezier(.5,.05,.91,.47);
 }
 28%, 38% {
   transform: translateX(-2em);
 }
 40%, 45% {
   transform: translateX(-4em);
 }
 50%, 52% {
   transform: translateX(-4em) rotateZ(-20deg);
 }
 70%, 75% {
   transform: translateX(-4em) rotateZ(-10deg);
 }
 78% {
   transform: translateX(-4em) rotateZ(-24deg);
   opacity: 1;
 }
 86%, 100% {
   transform: translateX(-6em) translateY(4em) rotateZ(-90deg);
   opacity: 0;
 }
}

/* General styling */
body {
 margin: 0;
 background: #e9b59f;
 font-family: HelveticaNeue, Arial, Sans-serif;
 color: #fff;
}

h1 {
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
 text-align: center;
 font-weight: 300;
}

h2 {
 font-size: 0.75em;
 position: absolute;
 bottom: 0;
 left: 0;
 right: 0;
 text-align: center;
}

a {
 text-decoration: none;
 color: #333;
}

.principle {
 width: 100%;
 height: 100vh;
 position: relative;
}

.shape {
 background: #2d97db;
 border: 1em solid #fff;
 width: 4em;
 height: 4em;
 position: absolute;
 top: calc(50% - 2em);
 left: calc(50% - 2em);
}

—— END ——

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019.03.26 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 预备动作 (Anticipation)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档