Workaround for safari's buggy rendering of inner SVG Animation? - javascript

I'm looking for a workaround for safari's buggy rendering of inner SVG with CSS Animations.
Here it is on codepen.
Chrome does this perfectly well, but in Safari the transitioning within the animation doesn't render until it jumps between states.
What is causing it?
Relevant CSS3
.avatar {
z-index: 800;
}
.avatar path {
stroke: #e1afff;
stroke-width: 0.15;
-webkit-transform-origin: center center;
transform-origin: center center;
-webkit-transition: all 6s ease;
transition: all 6s ease;
-webkit-transform: translate(0);
transform: translate(0);
}
.avatar path:nth-of-type(4n+1) {
-webkit-animation: p1 3s ease 1;
animation: p1 3s ease 1;
}
.avatar path:nth-of-type(4n+2) {
-webkit-animation: p2 3s ease 1;
animation: p2 3s ease 1;
}
.avatar path:nth-of-type(4n+3) {
-webkit-animation: p3 3s ease 1;
animation: p3 3s ease 1;
}
.avatar path:nth-of-type(4n+4) {
-webkit-animation: p4 3s ease 1;
animation: p4 3s ease 1;
}
.hover {
position: absolute;
width: 40%;
height: 40vw;
top: 50%;
left: 30%;
margin-top: -20vw;
border-radius: 50%;
cursor: pointer;
z-index: 1000;
background: rgba(0,0,0,0);
-webkit-animation: waitforit 0 ease-in 3s 1 forwards;
animation: waitforit 0 ease-in 3s 1 forwards;
}
.hover:hover + .avatar path:nth-of-type(4n+1) {
-webkit-transform: translate(800%, 400%) rotate(-690deg) translateZ(0);
transform: translate(800%, 400%) rotate(-690deg) translateZ(0);
}
.hover:hover + .avatar path:nth-of-type(4n+2) {
-webkit-transform: translate(-700%, 600%) rotate(-720deg) translateZ(0);
transform: translate(-700%, 600%) rotate(-720deg) translateZ(0);
}
.hover:hover + .avatar path:nth-of-type(4n+3) {
-webkit-transform: translate(-900%, -500%) rotate(-820deg) translateZ(0);
transform: translate(-900%, -500%) rotate(-820deg) translateZ(0);
}
.hover:hover + .avatar path:nth-of-type(4n+4) {
-webkit-transform: translate(700%, -800%) rotate(-950deg) translateZ(0);
transform: translate(700%, -800%) rotate(-950deg) translateZ(0);
}
#-webkit-keyframes p1 {
0% {
-webkit-transform: translate(-300%, -700%) rotate(520deg) translateZ(0);
transform: translate(-300%, -700%) rotate(520deg) translateZ(0);
}
100% {
-webkit-transform: translate(0);
transform: translate(0);
}
}
#keyframes p1 {
0% {
-webkit-transform: translate(-300%, -700%) rotate(520deg) translateZ(0);
transform: translate(-300%, -700%) rotate(520deg) translateZ(0);
}
100% {
-webkit-transform: translate(0);
transform: translate(0);
}
}
#-webkit-keyframes p2 {
0% {
-webkit-transform: translate(400%, -900%) rotate(850deg) translateZ(0);
transform: translate(400%, -900%) rotate(850deg) translateZ(0);
}
100% {
-webkit-transform: translate(0);
transform: translate(0);
}
}
#keyframes p2 {
0% {
-webkit-transform: translate(400%, -900%) rotate(850deg) translateZ(0);
transform: translate(400%, -900%) rotate(850deg) translateZ(0);
}
100% {
-webkit-transform: translate(0);
transform: translate(0);
}
}
#-webkit-keyframes p3 {
0% {
-webkit-transform: translate(500%, 900%) rotate(325deg) translateZ(0);
transform: translate(500%, 900%) rotate(325deg) translateZ(0);
}
100% {
-webkit-transform: translate(0);
transform: translate(0);
}
}
#keyframes p3 {
0% {
-webkit-transform: translate(500%, 900%) rotate(325deg) translateZ(0);
transform: translate(500%, 900%) rotate(325deg) translateZ(0);
}
100% {
-webkit-transform: translate(0);
transform: translate(0);
}
}
#-webkit-keyframes p4 {
0% {
-webkit-transform: translate(-500%, 900%) rotate(748deg) translateZ(0);
transform: translate(-500%, 900%) rotate(748deg) translateZ(0);
}
100% {
-webkit-transform: translate(0);
transform: translate(0);
}
}
#keyframes p4 {
0% {
-webkit-transform: translate(-500%, 900%) rotate(748deg) translateZ(0);
transform: translate(-500%, 900%) rotate(748deg) translateZ(0);
}
100% {
-webkit-transform: translate(0);
transform: translate(0);
}
}
#-webkit-keyframes waitforit {
0% {
display: none;
}
100% {
display: block;
}
}
#keyframes waitforit {
0% {
display: none;
}
100% {
display: block;
}
}
The vendor prefix -webkit- applies to both Chrome & Safari. Safari is known to be buggy in rendering inner SVG animations, however there is usually a happy medium. Can anyone think of a workaround of sorts? Maybe an easy js fix?

Related

Why does the last frame show up before first in animation?

I was trying to make a "bounce-in" effect where the circle isn't there before the animation, then the animation is executed on scroll, and the circle remains there after the animation is over. But for some reason it's there even before the animation, then disappears (since first frame opacity is 0) then appears again. I'm not sure what I'm doing wrong.
if (browser.canUse('transition')) {
var on = function() {
// Circles
$('.circle')
.scrollex({
mode: 'bottom',
delay: 50,
initialize: function() {
$(this).addClass('bounceIn');
},
terminate: function() {
$(this).removeClass('bounceIn');
},
enter: function() {
$(this).removeClass('bounceIn');
},
leave: function() {
$(this).addClass('bounceIn');
}
});
.circle {
position: absolute;
border-radius: 50%;
}
.circle.circle1 {
top: 80px;
left: 120px;
width: 100px;
height: 100px;
background: white;
opacity: 0;
}
/* ----------- BOUNCE IN ------------*/
#-webkit-keyframes bounceIn {
from,
20%,
40%,
60%,
80%,
to {
-webkit-animation-timing-function: cubic-bezier(0.315, 0.71, 0.455, 1);
animation-timing-function: cubic-bezier(0.315, 0.71, 0.455, 1);
}
0% {
opacity: 0;
-webkit-transform: scale(0.3);
transform: scale(0.3);
}
20% {
-webkit-transform: scale(1.03);
transform: scale(1.03);
}
40% {
-webkit-transform: scale(0.9);
transform: scale(0.9);
}
60% {
opacity: 1;
-webkit-transform: scale(1.03);
transform: scale(1.03);
}
80% {
-webkit-transform: scale(0.97);
transform: scale(0.97);
}
to {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1);
}
}
#keyframes bounceIn {
from,
20%,
40%,
60%,
80%,
to {
-webkit-animation-timing-function: cubic-bezier(0.315, 0.71, 0.455, 1);
animation-timing-function: cubic-bezier(0.315, 0.71, 0.455, 1);
}
0% {
opacity: 0;
-webkit-transform: scale(0.3);
transform: scale(0.3);
}
20% {
-webkit-transform: scale(1.03);
transform: scale(1.03);
}
40% {
-webkit-transform: scale(0.9);
transform: scale(0.9);
}
60% {
opacity: 1;
-webkit-transform: scale(1.03);
transform: scale(1.03);
}
80% {
-webkit-transform: scale(0.97);
transform: scale(0.97);
}
to {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1);
}
}
.bounceIn {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-name: bounceIn;
animation-name: bounceIn;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
<div class="circle circle1"></div>

preloader for part of content in current theme wp

I need to show preloader only in 'content' div, but preloader hides entire page. Structure site:
Title
Menu
Content (here i need preloader)
Footer
I can't find, where i need insert my code of preloader...
src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"
$(window).load(function() {
$(".cssload-loader").delay(1400).fadeOut();
$(".preloader").delay(1500).fadeOut("slow");
})
.preloader {
position: fixed;
background-color: #fff;
z-index: 107;
height: 100%;
width: 100%;
}
.cssload-loader {
position: absolute;
left: 50%;
top: 50%;
width: 34.284271247462px;
height: 34.284271247462px;
margin-left: -17.142135623731px;
margin-top: -17.142135623731px;
border-radius: 100%;
animation-name: cssload-loader;
-o-animation-name: cssload-loader;
-ms-animation-name: cssload-loader;
-webkit-animation-name: cssload-loader;
-moz-animation-name: cssload-loader;
animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
-ms-animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
animation-timing-function: linear;
-o-animation-timing-function: linear;
-ms-animation-timing-function: linear;
-webkit-animation-timing-function: linear;
-moz-animation-timing-function: linear;
animation-duration: 2.8s;
-o-animation-duration: 2.8s;
-ms-animation-duration: 2.8s;
-webkit-animation-duration: 2.8s;
-moz-animation-duration: 2.8s;
}
.cssload-loader .cssload-side {
display: block;
width: 4px;
height: 14px;
background-color: rgba(0,0,0,0.81);
margin: 1px;
position: absolute;
border-radius: 50%;
animation-duration: 1.045s;
-o-animation-duration: 1.045s;
-ms-animation-duration: 1.045s;
-webkit-animation-duration: 1.045s;
-moz-animation-duration: 1.045s;
animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
-ms-animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
animation-timing-function: ease;
-o-animation-timing-function: ease;
-ms-animation-timing-function: ease;
-webkit-animation-timing-function: ease;
-moz-animation-timing-function: ease;
}
.cssload-loader .cssload-side:nth-child(1),
.cssload-loader .cssload-side:nth-child(5) {
transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
animation-name: cssload-rotate0;
-o-animation-name: cssload-rotate0;
-ms-animation-name: cssload-rotate0;
-webkit-animation-name: cssload-rotate0;
-moz-animation-name: cssload-rotate0;
}
.cssload-loader .cssload-side:nth-child(3),
.cssload-loader .cssload-side:nth-child(7) {
transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
animation-name: cssload-rotate90;
-o-animation-name: cssload-rotate90;
-ms-animation-name: cssload-rotate90;
-webkit-animation-name: cssload-rotate90;
-moz-animation-name: cssload-rotate90;
}
.cssload-loader .cssload-side:nth-child(2),
.cssload-loader .cssload-side:nth-child(6) {
transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
animation-name: cssload-rotate45;
-o-animation-name: cssload-rotate45;
-ms-animation-name: cssload-rotate45;
-webkit-animation-name: cssload-rotate45;
-moz-animation-name: cssload-rotate45;
}
.cssload-loader .cssload-side:nth-child(4),
.cssload-loader .cssload-side:nth-child(8) {
transform: rotate(135deg);
-o-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
animation-name: cssload-rotate135;
-o-animation-name: cssload-rotate135;
-ms-animation-name: cssload-rotate135;
-webkit-animation-name: cssload-rotate135;
-moz-animation-name: cssload-rotate135;
}
.cssload-loader .cssload-side:nth-child(1) {
top: 17.142135623731px;
left: 34.284271247462px;
margin-left: -2px;
margin-top: -7px;
animation-delay: 0;
-o-animation-delay: 0;
-ms-animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
}
.cssload-loader .cssload-side:nth-child(2) {
top: 29.213203431093px;
left: 29.213203431093px;
margin-left: -2px;
margin-top: -7px;
animation-delay: 0;
-o-animation-delay: 0;
-ms-animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
}
.cssload-loader .cssload-side:nth-child(3) {
top: 34.284271247462px;
left: 17.142135623731px;
margin-left: -2px;
margin-top: -7px;
animation-delay: 0;
-o-animation-delay: 0;
-ms-animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
}
.cssload-loader .cssload-side:nth-child(4) {
top: 29.213203431093px;
left: 5.0710678163691px;
margin-left: -2px;
margin-top: -7px;
animation-delay: 0;
-o-animation-delay: 0;
-ms-animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
}
.cssload-loader .cssload-side:nth-child(5) {
top: 17.142135623731px;
left: 0px;
margin-left: -2px;
margin-top: -7px;
animation-delay: 0;
-o-animation-delay: 0;
-ms-animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
}
.cssload-loader .cssload-side:nth-child(6) {
top: 5.0710678163691px;
left: 5.0710678163691px;
margin-left: -2px;
margin-top: -7px;
animation-delay: 0;
-o-animation-delay: 0;
-ms-animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
}
.cssload-loader .cssload-side:nth-child(7) {
top: 0px;
left: 17.142135623731px;
margin-left: -2px;
margin-top: -7px;
animation-delay: 0;
-o-animation-delay: 0;
-ms-animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
}
.cssload-loader .cssload-side:nth-child(8) {
top: 5.0710678163691px;
left: 29.213203431093px;
margin-left: -2px;
margin-top: -7px;
animation-delay: 0;
-o-animation-delay: 0;
-ms-animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
}
#keyframes cssload-rotate0 {
0% {
transform: rotate(0deg);
}
60% {
transform: rotate(180deg);
}
100% {
transform: rotate(180deg);
}
}
#-o-keyframes cssload-rotate0 {
0% {
-o-transform: rotate(0deg);
}
60% {
-o-transform: rotate(180deg);
}
100% {
-o-transform: rotate(180deg);
}
}
#-ms-keyframes cssload-rotate0 {
0% {
-ms-transform: rotate(0deg);
}
60% {
-ms-transform: rotate(180deg);
}
100% {
-ms-transform: rotate(180deg);
}
}
#-webkit-keyframes cssload-rotate0 {
0% {
-webkit-transform: rotate(0deg);
}
60% {
-webkit-transform: rotate(180deg);
}
100% {
-webkit-transform: rotate(180deg);
}
}
#-moz-keyframes cssload-rotate0 {
0% {
-moz-transform: rotate(0deg);
}
60% {
-moz-transform: rotate(180deg);
}
100% {
-moz-transform: rotate(180deg);
}
}
#keyframes cssload-rotate90 {
0% {
transform: rotate(90deg);
transform: rotate(90deg);
}
60% {
transform: rotate(270deg);
transform: rotate(270deg);
}
100% {
transform: rotate(270deg);
transform: rotate(270deg);
}
}
#-o-keyframes cssload-rotate90 {
0% {
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
60% {
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
100% {
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
}
#-ms-keyframes cssload-rotate90 {
0% {
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
60% {
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}
100% {
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}
}
#-webkit-keyframes cssload-rotate90 {
0% {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
60% {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
100% {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
}
#-moz-keyframes cssload-rotate90 {
0% {
-moz-transform: rotate(90deg);
transform: rotate(90deg);
}
60% {
-moz-transform: rotate(270deg);
transform: rotate(270deg);
}
100% {
-moz-transform: rotate(270deg);
transform: rotate(270deg);
}
}
#keyframes cssload-rotate45 {
0% {
transform: rotate(45deg);
transform: rotate(45deg);
}
60% {
transform: rotate(225deg);
transform: rotate(225deg);
}
100% {
transform: rotate(225deg);
transform: rotate(225deg);
}
}
#-o-keyframes cssload-rotate45 {
0% {
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
60% {
-o-transform: rotate(225deg);
transform: rotate(225deg);
}
100% {
-o-transform: rotate(225deg);
transform: rotate(225deg);
}
}
#-ms-keyframes cssload-rotate45 {
0% {
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
60% {
-ms-transform: rotate(225deg);
transform: rotate(225deg);
}
100% {
-ms-transform: rotate(225deg);
transform: rotate(225deg);
}
}
#-webkit-keyframes cssload-rotate45 {
0% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
60% {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
100% {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
}
#-moz-keyframes cssload-rotate45 {
0% {
-moz-transform: rotate(45deg);
transform: rotate(45deg);
}
60% {
-moz-transform: rotate(225deg);
transform: rotate(225deg);
}
100% {
-moz-transform: rotate(225deg);
transform: rotate(225deg);
}
}
#keyframes cssload-rotate135 {
0% {
transform: rotate(135deg);
transform: rotate(135deg);
}
60% {
transform: rotate(315deg);
transform: rotate(315deg);
}
100% {
transform: rotate(315deg);
transform: rotate(315deg);
}
}
#-o-keyframes cssload-rotate135 {
0% {
-o-transform: rotate(135deg);
transform: rotate(135deg);
}
60% {
-o-transform: rotate(315deg);
transform: rotate(315deg);
}
100% {
-o-transform: rotate(315deg);
transform: rotate(315deg);
}
}
#-ms-keyframes cssload-rotate135 {
0% {
-ms-transform: rotate(135deg);
transform: rotate(135deg);
}
60% {
-ms-transform: rotate(315deg);
transform: rotate(315deg);
}
100% {
-ms-transform: rotate(315deg);
transform: rotate(315deg);
}
}
#-webkit-keyframes cssload-rotate135 {
0% {
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
60% {
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}
100% {
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}
}
#-moz-keyframes cssload-rotate135 {
0% {
-moz-transform: rotate(135deg);
transform: rotate(135deg);
}
60% {
-moz-transform: rotate(315deg);
transform: rotate(315deg);
}
100% {
-moz-transform: rotate(315deg);
transform: rotate(315deg);
}
}
#keyframes cssload-loader {
0% {
transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
transform: rotate(360deg);
}
}
#-o-keyframes cssload-loader {
0% {
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#-ms-keyframes cssload-loader {
0% {
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#-webkit-keyframes cssload-loader {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#-moz-keyframes cssload-loader {
0% {
-moz-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(360deg);
transform: rotate(360deg);
}
}
<?php
get_header();
get_template_part('index', 'banner');
?>
<!-- Blog Full Width Section -->
<div class="blog-section">
<div class="container">
<div class="row">
<!--Blog Area-->
<div class="<?php elitepress_post_layout_class(); ?>" >
<?php get_template_part('content',''); ?>
<?php comments_template('',true); ?>
</div>
<!--/Blog Area-->
<div class="preloader" style="display: block;">
<div class="cssload-loader" style="display: block;">
<div class="cssload-side"></div>
<div class="cssload-side"></div>
<div class="cssload-side"></div>
<div class="cssload-side"></div>
<div class="cssload-side"></div>
<div class="cssload-side"></div>
<div class="cssload-side"></div>
<div class="cssload-side"></div>
</div>
</div>
<?php get_sidebar(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
<!-- /Blog Full Width Section -->
A simple solution using a FontAwesome spinner. Colors used are for visualization only.
$(".spinner").delay(1400).fadeOut();
header,
nav,
footer {
width: 100%;
height: 50px;
}
header {
background-color: red;
}
nav {
background-color: blue;
}
footer {
background-color: green;
}
.content {
width: 100%;
height: 200px;
position: relative;
}
.spinner {
width: 100%;
height: 100%;
background-color: purple;
text-align: center;
display: table;
}
.spinner i {
display: table-cell;
vertical-align: middle;
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<header></header>
<nav></nav>
<div class="content">
<div class="spinner"><i class="fa fa-spinner fa-spin fa-3x fa-fw"></i></div>
</div>
<footer></footer>

replace css animation without changing the position of the div

This is my code
https://jsfiddle.net/sameh0/hgk2uLfk/2/
I want to change the animation of rightleft when hovering over the div. However when I do that, the position of the div gets back first and then changes the animation which creates a bad interaction experience.
That being said I'm open to add any JS/JQuery code.
Currently when the div is hovered it's stopped in its initial position and the new animation bubble takes place.
MY GOAL IS :
to make the div stop at it's current position and the new animation bubble starts while the div is stopped .
and this is the code
HTML
<div class="circle"></div>
CSS
.circle{
-moz-border-radius: 100%;
-webkit-border-radius: 100%;
border-radius: 100%;
position: absolute;
z-index: 100;
cursor: pointer;
top:25%;
left :28%;
width: 90px;
height: 90px;
-webkit-animation: rightleft 2.5s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955) , bubble 2s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955);
-moz-animation: rightleft 2.5s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955),bubble 2s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955);
animation: rightleft 2.5s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955),bubble 2s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955) ;
background-color:blue;
background-size: 80%;
}
.circle:hover{
background-color:red;
-webkit-animation: bubble, 0.8s infinite alternate cubic-bezier(0.46, 0.03, 1, 0.21) !important;
-moz-animation: bubble 0.8s infinite alternate cubic-bezier(0.46, 0.03, 1, 0.21) !important;
animation: bubble 0.8s infinite alternate cubic-bezier(0.46, 0.03, 1, 0.21) !important;
}
#-webkit-keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -30px;
margin-top: -30px;
}
}
#-moz-keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -30px;
margin-top: -30px;
}
}
#-ms-keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -30px;
margin-top: -30px;
}
}
#keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -30px;
margin-top: -30px;
}
}
#-webkit-keyframes bubble {
0% {
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
}
}
#-moz-keyframes bubble {
0% {
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
}
}
#-ms-keyframes bubble {
0% {
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
}
}
#keyframes bubble {
0% {
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
}
}
How about the following code?
.circle{
background-color:blue;
animation:
rightleft 2.5s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955),
bubble 2s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955) ;
}
.circle:hover{
background-color:red;
animation:
rightleft 2.5s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955),
bubble 0.8s infinite alternate cubic-bezier(0.46, 0.03, 1, 0.21);
animation-play-state: paused, running;
}
#keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -100px;
margin-top: -100px;
}
}
#keyframes bubble {
0% {
transform: scale(0.9);
}
100% {
transform: scale(1.1);
}
}
DEMO
https://jsfiddle.net/hgk2uLfk/10/
Updated
<div class="circle">
<div class="bubble"></div>
</div>
.circle{
position: absolute;
z-index: 100;
top:25%;
left :28%;
-webkit-animation: rightleft 2.5s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955) , bubble 2s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955);
-moz-animation: rightleft 2.5s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955),bubble 2s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955);
animation: rightleft 2.5s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955),bubble 2s infinite alternate cubic-bezier(0.455, 0.03, 0.515, 0.955) ;
}
.circle:hover {
-webkit-animation-play-state: paused;
-moz-animation-play-state: paused;
-o-animation-play-state: paused;
animation-play-state: paused;
}
.bubble {
width: 90px;
height: 90px;
cursor: pointer;
-moz-border-radius: 100%;
-webkit-border-radius: 100%;
border-radius: 100%;
background-color:blue;
background-size: 80%;
}
.bubble:hover{
background-color:red;
-webkit-animation: bubble, 0.8s infinite alternate cubic-bezier(0.46, 0.03, 1, 0.21) !important;
-moz-animation: bubble 0.8s infinite alternate cubic-bezier(0.46, 0.03, 1, 0.21) !important;
animation: bubble 0.8s infinite alternate cubic-bezier(0.46, 0.03, 1, 0.21) !important;
}
#-webkit-keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -30px;
margin-top: -30px;
}
}
#-moz-keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -30px;
margin-top: -30px;
}
}
#-ms-keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -30px;
margin-top: -30px;
}
}
#keyframes rightleft {
0% {
margin-top: 0px;
margin-left: 0px;
}
100% {
margin-left: -30px;
margin-top: -30px;
}
}
#-webkit-keyframes bubble {
0% {
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
}
}
#-moz-keyframes bubble {
0% {
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
}
}
#-ms-keyframes bubble {
0% {
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
}
}
#keyframes bubble {
0% {
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
}
}
add this code to the previous code and it will work
.circle:hover {
animation-name: rightleft;
animation-play-state: paused;
}

Using jQuery to restart an animation that is already hidden and transparent

I have a CSS animation which goes from Visible to hidden and solid to transparent at the same time. My problem is, this is an animation which I need to display when a button is clicked. How do I trigger the event on click, when the actual hiding and fading is performed by CSS and not jQuery? For example, when Div 'One' is clicked, I want the overlay to play once. Same when the other divs are clicked. I can't seem to work it out, and help would be great!
$(".btn").click(function() {
var el = $(".overlay"),
newone = el.clone(true);
el.before(newone);
$("." + el.attr("class") + ":last").remove();
});
.overlay {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: table;
background-color:rgb(39, 174, 96);
z-index: 10;
}
h1.thank-you-message { font-size:12.0rem;display: table-cell; color:#fff; text-align: center;
vertical-align: middle;-webkit-perspective: 1000;-webkit-font-smoothing: antialiased;}
.animated-thank-you {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
#-webkit-keyframes fadeOutScale {
0% {visibility:visible; opacity: 1;transform: scale(1); /* CSS3 */
-moz-transform: scale(1); /* Firefox */
-webkit-transform: scale(1); /* Webkit */
-o-transform: scale(1); /* Opera */
-ms-transform: scale(1); /* IE 9 */}
40% {opacity: 1;transform: transform: scale(0.75); /* CSS3 */
-moz-transform: scale(0.75); /* Firefox */
-webkit-transform: scale(0.75); /* Webkit */
-o-transform: scale(0.75); /* Opera */
-ms-transform: scale(0.75); /* IE 9 */}
60% {opacity: 1;transform: transform: scale(0.75); /* CSS3 */
-moz-transform: scale(0.75); /* Firefox */
-webkit-transform: scale(0.75); /* Webkit */
-o-transform: scale(0.75); /* Opera */
-ms-transform: scale(0.75); /* IE 9 */}
100% {visibility:hidden; opacity: 0;
transform: -moz-transform: scale(0.5); /* Firefox */
-webkit-transform: scale(0.5); /* Webkit */
-o-transform: scale(0.5); /* Opera */
-ms-transform: scale(0.5); /* IE 9 */}
}
#keyframes fadeOutScale {
0% {visibility:visible; opacity: 1; transform: scale(1);}
40% {opacity: 1;transform: scale(0.75);}
60% {opacity: 1;transform: scale(0.75);}
100% {visibility:hidden;opacity: 0; transform: scale(0.5);}
}
.fadeOutScale {
-webkit-animation-name: fadeOutScale;
animation-name: fadeOutScale;
}
.animated-fade-out {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
#-webkit-keyframes fadeOut {
0% {visibility:visible; opacity: 1;}
40% {opacity: 1;}
60% {opacity: 1;}
100% {visibility:hidden;opacity: 0;}
}
#keyframes fadeOut {
0% {visibility:visible; opacity: 1;}
40% {opacity: 1;}
60% {opacity: 1;}
100% {visibility:hidden;opacity: 0;}
}
.fadeOut {
-webkit-animation-name: fadeOut;
animation-name: fadeOut;
}
<div class="overlay animated-fade-out fadeOut"><h1 class="thank-you-message animated-thank-you fadeOutScale">Thank You</h1></div>
<div class="btn" style="height:20px;">ONE</div>
<div class="btn" style="height:20px;">two</div>
<div class="btn" style="height:20px;">three</div>
function runAnimation () {
$('.overlay').removeClass('animated-fade-out fadeOut');
$('.overlay h1').removeClass('fadeOutScale');
setTimeout(function() {
$('.overlay').addClass('animated-fade-out fadeOut');
$('.overlay h1').addClass('fadeOutScale');
});
}
$(runAnimation);
$('#one').click(runAnimation);
.overlay {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: table;
background-color:rgb(39, 174, 96);
z-index: 10;
}
h1.thank-you-message { font-size:12.0rem;display: table-cell; color:#fff; text-align: center;
vertical-align: middle;-webkit-perspective: 1000;-webkit-font-smoothing: antialiased;}
.animated-thank-you {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
#-webkit-keyframes fadeOutScale {
0% {visibility:visible; opacity: 1;transform: scale(1); /* CSS3 */
-moz-transform: scale(1); /* Firefox */
-webkit-transform: scale(1); /* Webkit */
-o-transform: scale(1); /* Opera */
-ms-transform: scale(1); /* IE 9 */}
40% {opacity: 1;transform: transform: scale(0.75); /* CSS3 */
-moz-transform: scale(0.75); /* Firefox */
-webkit-transform: scale(0.75); /* Webkit */
-o-transform: scale(0.75); /* Opera */
-ms-transform: scale(0.75); /* IE 9 */}
60% {opacity: 1;transform: transform: scale(0.75); /* CSS3 */
-moz-transform: scale(0.75); /* Firefox */
-webkit-transform: scale(0.75); /* Webkit */
-o-transform: scale(0.75); /* Opera */
-ms-transform: scale(0.75); /* IE 9 */}
100% {visibility:hidden; opacity: 0;
transform: -moz-transform: scale(0.5); /* Firefox */
-webkit-transform: scale(0.5); /* Webkit */
-o-transform: scale(0.5); /* Opera */
-ms-transform: scale(0.5); /* IE 9 */}
}
#keyframes fadeOutScale {
0% {visibility:visible; opacity: 1; transform: scale(1);}
40% {opacity: 1;transform: scale(0.75);}
60% {opacity: 1;transform: scale(0.75);}
100% {visibility:hidden;opacity: 0; transform: scale(0.5);}
}
.fadeOutScale {
-webkit-animation-name: fadeOutScale;
animation-name: fadeOutScale;
}
.animated-fade-out {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
#-webkit-keyframes fadeOut {
0% {visibility:visible; opacity: 1;}
40% {opacity: 1;}
60% {opacity: 1;}
100% {visibility:hidden;opacity: 0;}
}
#keyframes fadeOut {
0% {visibility:visible; opacity: 1;}
40% {opacity: 1;}
60% {opacity: 1;}
100% {visibility:hidden;opacity: 0;}
}
.fadeOut {
-webkit-animation-name: fadeOut;
animation-name: fadeOut;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="overlay"><h1 class="thank-you-message animated-thank-you">Thank You</h1></div>
<div id="one" style="height:20px;">ONE</div>
<div id="two" style="height:20px;">two</div>
<div id="three" style="height:20px;">three</div>
$(".btn").click(function() {
var $elOvl = $('.overlay'),
$elThx = $('.thank-you-message');
function addAnimationClasses() {
$elOvl.addClass('fadeOut');
$elThx.addClass('fadeOutScale');
}
$elOvl.removeClass('fadeOut');
$elThx.removeClass('fadeOutScale');
/*
We need to add classes AFTER they have been removed,
so we postpone the adding of classes to the next frame with the next line.
*/
setTimeout(addAnimationClasses, 0);
});
.btn {
background: #3c9;
margin: 9px 0;
padding: 3px;
}
.overlay {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: table;
background-color: rgb(39, 174, 96);
z-index: 10;
}
h1.thank-you-message {
font-size: 12.0rem;
display: table-cell;
color: #fff;
text-align: center;
vertical-align: middle;
-webkit-perspective: 1000;
-webkit-font-smoothing: antialiased;
}
.animated-thank-you {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
#-webkit-keyframes fadeOutScale {
0% {
visibility: visible;
opacity: 1;
transform: scale(1);
/* CSS3 */
-moz-transform: scale(1);
/* Firefox */
-webkit-transform: scale(1);
/* Webkit */
-o-transform: scale(1);
/* Opera */
-ms-transform: scale(1);
/* IE 9 */
}
40% {
opacity: 1;
transform: transform: scale(0.75);
/* CSS3 */
-moz-transform: scale(0.75);
/* Firefox */
-webkit-transform: scale(0.75);
/* Webkit */
-o-transform: scale(0.75);
/* Opera */
-ms-transform: scale(0.75);
/* IE 9 */
}
60% {
opacity: 1;
transform: transform: scale(0.75);
/* CSS3 */
-moz-transform: scale(0.75);
/* Firefox */
-webkit-transform: scale(0.75);
/* Webkit */
-o-transform: scale(0.75);
/* Opera */
-ms-transform: scale(0.75);
/* IE 9 */
}
100% {
visibility: hidden;
opacity: 0;
transform: -moz-transform: scale(0.5);
/* Firefox */
-webkit-transform: scale(0.5);
/* Webkit */
-o-transform: scale(0.5);
/* Opera */
-ms-transform: scale(0.5);
/* IE 9 */
}
}
#keyframes fadeOutScale {
0% {
visibility: visible;
opacity: 1;
transform: scale(1);
}
40% {
opacity: 1;
transform: scale(0.75);
}
60% {
opacity: 1;
transform: scale(0.75);
}
100% {
visibility: hidden;
opacity: 0;
transform: scale(0.5);
}
}
.fadeOutScale {
-webkit-animation-name: fadeOutScale;
animation-name: fadeOutScale;
}
.animated-fade-out {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
#-webkit-keyframes fadeOut {
0% {
visibility: visible;
opacity: 1;
}
40% {
opacity: 1;
}
60% {
opacity: 1;
}
100% {
visibility: hidden;
opacity: 0;
}
}
#keyframes fadeOut {
0% {
visibility: visible;
opacity: 1;
}
40% {
opacity: 1;
}
60% {
opacity: 1;
}
100% {
visibility: hidden;
opacity: 0;
}
}
.fadeOut {
-webkit-animation-name: fadeOut;
animation-name: fadeOut;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<div class="overlay animated-fade-out fadeOut">
<h1 class="thank-you-message animated-thank-you fadeOutScale">Thank You</h1>
</div>
<div class="btn">ONE</div>
<div class="btn">two</div>
<div class="btn">three</div>
To start an animation on an element, you need to add a class to it. In your case fadeOut and fadeOutScale.
If you only want the animation to start on a click, you need to remove both your animation classes from your animated elements, so the animation doesn't start at load.
<div class="overlay animated-fade-out">
<h1 class="thank-you-message animated-thank-you">Thank You</h1>
</div>
<div class="btn" style="height:20px;">ONE</div>
<div class="btn" style="height:20px;">two</div>
<div class="btn" style="height:20px;">three</div>
And to start the animation, you need to add classes to your animated elements and later remove them, so you can later add them again, to start the animation again.
$(".btn").click(function() {
$(".overlay").addClass("fadeOut").one("animationend", function() {
$(this).removeClass("fadeOut").find(".thank-you-message").removeClass("fadeOutScale");
}).find(".thank-you-message").addClass("fadeOutScale");
});
It is not required to clone the overlay div for every click on btn div. Instead, just remove the classes applied for overlay div and h1 tag, and add the classes back after a small delay.
The script will look like:
$(".btn").click(function() {
$("#overlay").removeClass("overlay animated-fade-out fadeOut").hide();
$("#overlay h1").removeClass("thank-you-message animated-thank-you fadeOutScale");
setTimeout(function(){
$("#overlay").css('display','').addClass("overlay animated-fade-out fadeOut");
$("#overlay h1").addClass("thank-you-message animated-thank-you fadeOutScale");
},1);
});
See the code here:
https://jsfiddle.net/code/
Result here:
https://jsfiddle.net/result/

Seamlessly transition back and forth with only one animation class?

I want to use one class to trigger an animation, and upon removal of that class redo that animation in reverse.
It's hard to visualize, so I've created a CodePen of where I'm at currently.
You'll notice that when .zoom is removed from #box, the #box just vanishes. It doesn't do the animation in reverse, which is ultimately the goal.
How can I seamlessly transition back and forth, with only one animation class? Normally I might use transitions, but you can't transition with transforms.
Try adding .zoomout class , css animations , utilizing .removeClass() , second class at .toggleClass()
window.onclick = function() {
if (!$("#box").is(".zoom")) {
$("#box").removeClass("zoomout")
.toggleClass("zoom");
} else {
$("#box").toggleClass("zoom zoomout");
}
};
#box {
width: 256px;
height: 256px;
background: black;
opacity: 0;
display: block;
transform: scale(1.15, 1.15);
margin: 16px 0px;
}
.zoom {
animation: zoom 500ms;
animation-fill-mode: both;
-moz-animation: zoom 500ms;
-moz-animation-fill-mode: both;
-webkit-animation: zoom 500ms;
-webkit-animation-fill-mode: both;
}
.zoomout {
animation: zoomout 500ms;
animation-fill-mode: both;
-moz-animation: zoomout 500ms;
-moz-animation-fill-mode: both;
-webkit-animation: zoomout 500ms;
-webkit-animation-fill-mode: both;
}
#keyframes zoom {
0% {
opacity: 0;
transform: scale(1.15);
}
100% {
opacity: 1;
transform: scale(1);
}
}
#-moz-keyframes zoom {
0% {
opacity: 0;
transform: scale(1.15);
}
100% {
opacity: 1;
transform: scale(1);
}
}
#-webkit-keyframes zoom {
0% {
opacity: 0;
transform: scale(1.15);
}
100% {
opacity: 1;
transform: scale(1);
}
}
#keyframes zoomout {
0% {
opacity: 1;
transform: scale(1.15);
}
100% {
opacity: 0;
transform: scale(1);
}
}
#-moz-keyframes zoomout {
0% {
opacity: 1;
transform: scale(1.15);
}
100% {
opacity: 0;
transform: scale(1);
}
}
#-webkit-keyframes zoomout {
0% {
opacity: 1;
transform: scale(1.15);
}
100% {
opacity: 0;
transform: scale(1);
}
}
body {
margin: 0;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -60%);
-moz-transform: translate(-50%, -60%);
-webkit-transform: translate(-50%, -60%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<div id="box"></div>
Click the document to toggle the box.
codepen http://codepen.io/anon/pen/vOxxKE

Categories