Reputation: 7969
I have been trying to achieve the bubble explode like animation. Something similar to this http://taotajima.jp/works/the-9d-project/. When you click play button, you can see the bubble animation. I think they had made the animation in canvas
. I am trying to do it with the help of CSS skew property but not able to get it in a way it should be.
.wobble-top:hover {
width:160px;
animation-name: wobble-top;
animation-duration: 1s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
.wobble-top {
display: inline-block;
transform-origin: 0 100%;
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
background:black;
color:white;
height:120px;
width:120px;
line-height:120px;
text-align:center;
position:absolute;
right:0;
top:10px;
transition: width 0.3s ease-in-out;
border-radius: 60px
}
/* Wobble Top */
@keyframes wobble-top {
16.65% {
transform: skew(-12deg);
}
33.3% {
transform: skew(10deg);
border-radius:30px
}
49.95% {
transform: skew(-6deg);
width:50%;
height:50%;
border-radius:20px
}
66.6% {
transform: skew(4deg);
border-radius:10px;
width:70%;
height:70%;
}
83.25% {
transform: skew(-2deg);
width:80%;
height:80%;
border-radius:0px
}
100% {
transform: skew(0);
width:100%;
height:100%;
}
}
<a rel="wobble-top" class="button wobble-top" style="
">Wobble Top</a>
Upvotes: 0
Views: 1354
Reputation: 10081
I played a little with your code.
You must want to use animation-fill-mode:
forwards;
.
Then I guess you just need to play with the skew()
values (note that skew()
can take 2 values as parameters) to get to the way it should be. I kind of tried.
I slowed down a little the animation and commented the animation-iteration-count: infinite;
because I was starting to feel sick!…
(See comments in the code for details.)
.wobble-top:hover {
color: black;
/*width:160px; TAKIT: Remove that! */
animation-name: wobble-top;
animation-duration: 2s;
animation-timing-function: ease-out;
/*animation-iteration-count: infinite; TAKIT: Commented */
animation-fill-mode: forwards; /* TAKIT: Added */
}
.wobble-top {
display: inline-block;
transform-origin: 0 100%;
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
background: black;
color: white;
line-height: 120px;
text-align: center;
position: absolute;
right: 0;
top: 10px;
height: 120px;
width: 120px;
border-radius: 100%; /* TAKIT: Changed here */
transition: color 1s ease; /* TAKIT: Added */
}
/* Wobble Top */
@keyframes wobble-top {
30% {
transform: skew(0, -2deg);
height: 160px;
width: 240px;
}
50% {
transform: skew(6deg, 3deg);
}
60% {
transform: skew(-2deg, -4deg);
}
70% {
transform: skew(4deg, -6deg);
width: 50%;
height: 50%;
}
80% {
transform: skew(0, 0);
width: 75%;
height: 75%;
border-radius: 20%;
}
90% {
transform: skew(0, 0);
width: 90%;
height: 90%;
border-radius: 10%;
}
100% {
transform: skew(0, 0);
width: 100%;
height: 100%;
border-radius: 0%; /* TAKIT: Added to work with the "forwards" animation-fill-mode */
}
}
<a rel="wobble-top" class="button wobble-top">Wobble Top</a>
(Better rendering when using the full-page snippet)
Hope it helps.
Upvotes: 1