I dont know what im doin wrong here.
My animation worked fine till last days. After debugging ive seen the animationend event is not getting fired on my last two animations in the chain.
Fiddle here: https://jsfiddle.net/bn1krph7/
<div class="welcome-container"><div class="welcome-logo"><img src="https://placehold.it/250x250" class="welcome-avatar"></div><div class="welcome-title-container"><span class="welcome-title">Welcome, </span><span class="welcome-user">User!</span></div></div>
$(function() {
var container = $('.welcome-container');
var logo = document.querySelector('.welcome-logo');
logo.addEventListener('animationend', function(e) {
console.log(e.animationName);
}, false);;
setTimeout(function() {
container.addClass('visible');
}, 1000)
});
html, body {
height: 100%;
width: 100%;
}
.welcome-container {
opacity: 0;
display: none;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 0;
&.visible {
transition-property: opacity;
transition-duration: 450ms;
opacity: 1;
display: block;
z-index: 1;
}
}
.welcome-logo, .welcome-title-container {
position: relative;
left: 50%;
transform: translate3d(-50%, 0, 0);
}
.welcome-logo {
overflow: hidden;
border-radius: 50%;
border: 16px solid #434c53;
background-color: #ffffff;
transform-origin: center center;
width: 126px;
height: 126px;
transform: translate3d(-50%, 0, 0) scale(0.17);
top: 8.4%;
}
.welcome-avatar {
width: 100%;
height: 100%;
display: block;
opacity: 0;
}
.welcome-user {
opacity: 0;
color: #434c53;
}
.welcome-title {
opacity: 0;
color: #6D7579;
}
.welcome-title-container {
position: absolute;
font-size: 15px;
top: 63.3%;
}
.welcome-container.visible {
.welcome-logo {
animation-fill-mode: forwards;
animation-duration: .6s, .2s, .3s, .1s, .1s, .3s;
animation-name: logoMoveDown, logoSmall1, logoBig1, logoNormal, logoBig2, logoFadeOut;
animation-delay: 0s, 0.1s, 0.3s, 0.6s, 3.1s, 3.2s;
}
.welcome-avatar {
animation-fill-mode: forwards;
animation-duration: .2s;
animation-name: fade-in;
animation-delay: 0.3s;
}
.welcome-user {
animation-fill-mode: forwards;
animation-duration: 1s, .3s;
animation-name: fade-in, fade-out;
animation-delay: 1s, 3.2s;
}
.welcome-title {
animation-fill-mode: forwards;
animation-duration: 1s, .3s;
animation-name: fade-in, fade-out;
animation-delay: 0.8s, 3.2s;
}
}
#keyframes logoMoveDown {
from{
top: 8.4%;
}
to {
top: 39%;
}
}
#keyframes logoSmall1 {
from {
transform: translate3d(-50%, 0, 0) scale(0.17);
}
to {
transform: translate3d(-50%, 0, 0) scale(0.1);
}
}
#keyframes logoBig1 {
0% {
transform: translate3d(-50%, 0, 0) scale(0.1);
border-width: 16px;
}
50% {
border-width: 3px;
}
100% {
transform: translate3d(-50%, 0, 0) scale(1.2);
border-width: 3px;
}
}
#keyframes logoNormal {
from {
transform: translate3d(-50%, 0, 0) scale(1.2);
}
to {
transform: translate3d(-50%, 0, 0) scale(1);
}
}
#keyframes logoBig2 {
from {
transform: translate3d(-50%, 0, 0) scale(1);
}
to {
transform: translate3d(-50%, 0, 0) scale(1.2);
}
}
#keyframes logoFadeOut {
0% {
transform: translate3d(-50%, 0, 0) scale(1.2);
opacity: 1;
}
100% {
transform: translate3d(-50%, 0, 0) scale(0.2);
opacity: 0;
}
}
#keyframes fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#keyframes fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
Chrome is working fine. Safari (9.1.2) doesnt work!
Another funny issue ive found: With alt+tab out and back in the animation will get called to end aslong there is no iframe usage. So you cant see in the fiddle demo.
Related
I have created a ripple full page loader. I'm trying to create the one like here.
I want the code to be simple with no plugins ideally.
I can load the page preloader but am wondering how I get the loading page to disappear once the main page has loaded? The page just will not fade! Have researched and tried all sorts of methods.
This is the code so far:
// Page loading animation
$(window).on('load', function() {
if ($('.cover').length) {
$('.cover').parallax({
imageSrc: $('.cover').data('image'),
zIndex: '1'
});
}
$("#preloader").animate({
'opacity': '0'
}, 600, function() {
setTimeout(function() {
$("#preloader").css("visibility", "hidden").fadeOut();
}, 300);
});
});
#preloader {
overflow: hidden;
background-color: #fb5849;
left: 0;
right: 0;
top: 0;
bottom: 0;
position: fixed;
z-index: 99999;
color: #fff;
}
#preloader .jumper {
left: 0;
top: 0;
right: 0;
bottom: 0;
display: block;
position: absolute;
margin: auto;
width: 50px;
height: 50px;
}
#preloader .jumper>div {
background-color: #fff;
width: 10px;
height: 10px;
border-radius: 100%;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
position: absolute;
opacity: 0;
width: 50px;
height: 50px;
-webkit-animation: jumper 1s 0s linear infinite;
animation: jumper 1s 0s linear infinite;
}
#preloader .jumper>div:nth-child(2) {
-webkit-animation-delay: 0.33333s;
animation-delay: 0.33333s;
}
#preloader .jumper>div:nth-child(3) {
-webkit-animation-delay: 0.66666s;
animation-delay: 0.66666s;
}
#-webkit-keyframes jumper {
0% {
opacity: 0;
-webkit-transform: scale(0);
transform: scale(0);
}
5% {
opacity: 1;
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
opacity: 0;
}
}
#keyframes jumper {
0% {
opacity: 0;
-webkit-transform: scale(0);
transform: scale(0);
}
5% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<div id="preloader">
<div class="jumper">
<div></div>
<div></div>
<div></div>
</div>
</div>
You can do it as below, using vanilla JavaScript. You can adapt it for jQuery. Also you can remove that setTimout, added just for testing purpose.
window.addEventListener("load", () => {
setTimeout(() => {
document.getElementById("preloader").classList.add("hide");
}, 1000);
});
#preloader {
overflow: hidden;
background-color: #fb5849;
left: 0;
right: 0;
top: 0;
bottom: 0;
position: fixed;
z-index: 99999;
color: #fff;
opacity: 1;
transition: opacity 1s;
}
#preloader.hide {
opacity: 0;
pointer-events: none;
}
#preloader .jumper {
left: 0;
top: 0;
right: 0;
bottom: 0;
display: block;
position: absolute;
margin: auto;
width: 50px;
height: 50px;
}
#preloader .jumper > div {
background-color: #fff;
width: 10px;
height: 10px;
border-radius: 100%;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
position: absolute;
opacity: 0;
width: 50px;
height: 50px;
-webkit-animation: jumper 1s 0s linear infinite;
animation: jumper 1s 0s linear infinite;
}
#preloader .jumper > div:nth-child(2) {
-webkit-animation-delay: 0.33333s;
animation-delay: 0.33333s;
}
#preloader .jumper > div:nth-child(3) {
-webkit-animation-delay: 0.66666s;
animation-delay: 0.66666s;
}
#-webkit-keyframes jumper {
0% {
opacity: 0;
-webkit-transform: scale(0);
transform: scale(0);
}
5% {
opacity: 1;
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
opacity: 0;
}
}
#keyframes jumper {
0% {
opacity: 0;
-webkit-transform: scale(0);
transform: scale(0);
}
5% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<div id="preloader">
<div class="jumper">
<div></div>
<div></div>
<div></div>
</div>
</div>
I have a text which appears when I run contrastShow function like this:
const contrast = document.getElementById("contrast");
function contrastHide() {
//sfxPlay(sfx.caption_hide);
contrast.classList.add("contrastHide");
contrast.classList.remove("contrastShow");
}
function contrastShow(text) {
contrast.innerHTML = text;
contrast.classList.add("contrastShow");
contrast.classList.remove("contrastHide");
}
contrastShow("This is the text");
setTimeout(() => {
contrast.classList.add("zoomIn");
}, 3000);
.contrast-container {
overflow: hidden;
height: 10vh;
width: 100%;
z-index: 11;
/*outline: 0.1vw dashed orange;*/
}
.vertical-center-contrast {
position: absolute;
top: 73.5vh; /*top: 82vh;*/
padding-top: 10px;
margin: 0;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.contrast {
position: relative;
font-family: "Vazir";
direction: rtl;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 1);
text-align: center;
width: 100%;
font-size: 2vw;
color: rgb(248, 247, 250);
opacity: 0;
margin: 0 auto;
}
.contrastShow {
animation: contrastAnimeShow 0.3s ease-in-out;
animation-fill-mode: forwards ;
}
.contrastHide {
animation: contrastAnimeHide 0.3s ease-in-out;
animation-fill-mode: forwards ;
}
#-webkit-keyframes contrastAnimeShow {
0% { opacity: 0; top: 4vh }
100% { opacity: 1; top: 1.2vh }
}
#-webkit-keyframes contrastAnimeHide {
0% { opacity: 1; top: 1.2vh }
100% { opacity: 0; top: 4vh }
}
.zoomIn {
-webkit-animation: heartbeat 1.5s ease-in-out infinite both;
animation: heartbeat 1.5s ease-in-out infinite both;
}
#-webkit-keyframes heartbeat {
from {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: center center;
transform-origin: center center;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
to {
-webkit-transform: scale(2);
transform: scale(2);
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
}
<div class ="vertical-center-contrast contrast-container">
<p id="contrast" class="contrast"></p>
</div>
Then I want to animate the text by adding a new class attached to a keyframe animation (using a setTimeout at the very end f the code).
But unexpectedly the text just hides and there is no animation ?!
What I missed and how to fix this?
The heartbeat animation is running, your element is just hidden via opacity. You should set the initial value of .contrast opacity to 1 and use the backwards fill-mode. This way it doesn't fallback to 0 if you overwrite the animation.
const contrast = document.getElementById("contrast");
function contrastHide() {
//sfxPlay(sfx.caption_hide);
contrast.classList.add("contrastHide");
contrast.classList.remove("contrastShow");
}
function contrastShow(text) {
contrast.innerHTML = text;
contrast.classList.add("contrastShow");
contrast.classList.remove("contrastHide");
}
contrastShow("This is the text");
setTimeout(() => {
contrast.classList.add("zoomIn");
}, 3000);
.contrast-container {
overflow: hidden;
height: 10vh;
width: 100%;
z-index: 11;
/*outline: 0.1vw dashed orange;*/
}
.vertical-center-contrast {
position: absolute;
top: 73.5vh; /*top: 82vh;*/
padding-top: 10px;
margin: 0;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.contrast {
position: relative;
font-family: "Vazir";
direction: rtl;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 1);
text-align: center;
width: 100%;
font-size: 2vw;
color: rgb(248, 247, 250);
opacity: 1;
top: 1.2vh;
margin: 0 auto;
}
.contrastShow {
animation: contrastAnimeShow 0.3s ease-in-out;
animation-fill-mode: backwards ;
}
.contrastHide {
animation: contrastAnimeHide 0.3s ease-in-out;
animation-fill-mode: backwards ;
}
#-webkit-keyframes contrastAnimeShow {
0% { opacity: 0; top: 4vh }
100% { opacity: 1; top: 1.2vh }
}
#-webkit-keyframes contrastAnimeHide {
0% { opacity: 1; top: 1.2vh }
100% { opacity: 0; top: 4vh }
}
.zoomIn {
-webkit-animation: heartbeat 1.5s ease-in-out infinite both;
animation: heartbeat 1.5s ease-in-out infinite both;
}
#-webkit-keyframes heartbeat {
from {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: center center;
transform-origin: center center;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
to {
-webkit-transform: scale(2);
transform: scale(2);
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
}
}
<div class ="vertical-center-contrast contrast-container">
<p id="contrast" class="contrast"></p>
</div>
I currently am in the process of making an AngularJS web application from scratch and am new to AngularJS, which is important to note because I could always be missing something fundamental.
The issue is this:
I have a fully functional Noty dialog that works exactly as it should aside from having no background. I installed Noty using npm install noty and included its JavaScript and CSS files in my index HTML file.
<link href="node_modules/noty/lib/noty.css" rel="stylesheet">
<script src="node_modules/noty/lib/noty.js" type="text/javascript"></script>
The CSS file's contents:
.noty_layout_mixin, #noty_layout__top, #noty_layout__topLeft, #noty_layout__topCenter, #noty_layout__topRight, #noty_layout__bottom, #noty_layout__bottomLeft, #noty_layout__bottomCenter, #noty_layout__bottomRight, #noty_layout__center, #noty_layout__centerLeft, #noty_layout__centerRight {
position: fixed;
margin: 0;
padding: 0;
z-index: 9999999;
-webkit-transform: translateZ(0) scale(1, 1);
transform: translateZ(0) scale(1, 1);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-font-smoothing: subpixel-antialiased;
filter: blur(0);
-webkit-filter: blur(0);
max-width: 90%; }
#noty_layout__top {
top: 0;
left: 5%;
width: 90%; }
#noty_layout__topLeft {
top: 20px;
left: 20px;
width: 325px; }
#noty_layout__topCenter {
top: 5%;
left: 50%;
width: 325px;
-webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); }
#noty_layout__topRight {
top: 20px;
right: 20px;
width: 325px; }
#noty_layout__bottom {
bottom: 0;
left: 5%;
width: 90%; }
#noty_layout__bottomLeft {
bottom: 20px;
left: 20px;
width: 325px; }
#noty_layout__bottomCenter {
bottom: 5%;
left: 50%;
width: 325px;
-webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); }
#noty_layout__bottomRight {
bottom: 20px;
right: 20px;
width: 325px; }
#noty_layout__center {
top: 50%;
left: 50%;
width: 325px;
-webkit-transform: translate(-webkit-calc(-50% - .5px), -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(calc(-50% - .5px), calc(-50% - .5px)) translateZ(0) scale(1, 1); }
#noty_layout__centerLeft {
top: 50%;
left: 20px;
width: 325px;
-webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); }
#noty_layout__centerRight {
top: 50%;
right: 20px;
width: 325px;
-webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); }
.noty_progressbar {
display: none; }
.noty_has_timeout.noty_has_progressbar .noty_progressbar {
display: block;
position: absolute;
left: 0;
bottom: 0;
height: 3px;
width: 100%;
background-color: #646464;
opacity: 0.2;
filter: alpha(opacity=10); }
.noty_bar {
-webkit-backface-visibility: hidden;
-webkit-transform: translate(0, 0) translateZ(0) scale(1, 1);
-ms-transform: translate(0, 0) scale(1, 1);
transform: translate(0, 0) scale(1, 1);
-webkit-font-smoothing: subpixel-antialiased;
overflow: hidden; }
.noty_effects_open {
opacity: 0;
-webkit-transform: translate(50%);
-ms-transform: translate(50%);
transform: translate(50%);
-webkit-animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards; }
.noty_effects_close {
-webkit-animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards; }
.noty_fix_effects_height {
-webkit-animation: noty_anim_height 75ms ease-out;
animation: noty_anim_height 75ms ease-out; }
.noty_close_with_click {
cursor: pointer; }
.noty_close_button {
position: absolute;
top: 2px;
right: 2px;
font-weight: bold;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
background-color: rgba(0, 0, 0, 0.05);
border-radius: 2px;
cursor: pointer;
-webkit-transition: all .2s ease-out;
transition: all .2s ease-out; }
.noty_close_button:hover {
background-color: rgba(0, 0, 0, 0.1); }
.noty_modal {
position: fixed;
width: 100%;
height: 100%;
background-color: #000;
z-index: 10000;
opacity: .3;
left: 0;
top: 0; }
.noty_modal.noty_modal_open {
opacity: 0;
-webkit-animation: noty_modal_in .3s ease-out;
animation: noty_modal_in .3s ease-out; }
.noty_modal.noty_modal_close {
-webkit-animation: noty_modal_out .3s ease-out;
animation: noty_modal_out .3s ease-out;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards; }
#-webkit-keyframes noty_modal_in {
100% {
opacity: .3; } }
#keyframes noty_modal_in {
100% {
opacity: .3; } }
#-webkit-keyframes noty_modal_out {
100% {
opacity: 0; } }
#keyframes noty_modal_out {
100% {
opacity: 0; } }
#keyframes noty_modal_out {
100% {
opacity: 0; } }
#-webkit-keyframes noty_anim_in {
100% {
-webkit-transform: translate(0);
transform: translate(0);
opacity: 1; } }
#keyframes noty_anim_in {
100% {
-webkit-transform: translate(0);
transform: translate(0);
opacity: 1; } }
#-webkit-keyframes noty_anim_out {
100% {
-webkit-transform: translate(50%);
transform: translate(50%);
opacity: 0; } }
#keyframes noty_anim_out {
100% {
-webkit-transform: translate(50%);
transform: translate(50%);
opacity: 0; } }
#-webkit-keyframes noty_anim_height {
100% {
height: 0; } }
#keyframes noty_anim_height {
100% {
height: 0; } }
/*# sourceMappingURL=noty.css.map*/
The only other places I have seen this issue posted, the answer was just "You forgot to include CSS files." However, I have done a little digging and I don't see what I could be missing.
Thank you in advance for suggestions/solutions
I appreciate your time and help.
I've had the same issue. I fixed it by adding the following two lines in my app.scss:
#import "~noty/src/noty.scss";
#import "~noty/src/themes/mint.scss";
I build something that should display words randomly and animate them.
What I want is a smooth scaling animation and a smooth fading out(blur) animation.
I have almost archive it but doesn't look smooth and I'd love to integrate Greensock using TweenMax with it. Is anyone able to help me to integrate TweenMax with it?
[
var interval = 600;
var width = 800;
var height = 300;
var words = [
'Liberty',
'Morality',
'Modesty',
'Curiosity',
'Imagination',
'Excitement',
'Structure',
'Intellect',
'Friendliness',
'Conversation'
];
var wordPlacementInterval = setInterval(function() {
var currentWord = words.shift();
if (currentWord) {
var word = document.createElement('span');
word.innerHTML = currentWord;
word.style.top = Math.floor((Math.random() * height) + 1) + 'px';
word.style.left = Math.floor((Math.random() * width) + 1) + 'px';
document.body.appendChild(word);
document.querySelector('#wordcloud').appendChild(word);
} else {
clearInterval(wordPlacementInterval);
}
}, interval);
//Something like this ? how can I implement this?
var scale_tween = TweenMax.to('span', 1, {
transform: 'scale(.75)',
ease: Linear.easeNone
});
#wordcloud span {
text-align: center;
font-size: 3rem;
opacity: 1;
display: inline-block;
transform-origin: bottom;
transition: all 500ms ease-in-out;
display: block;
position: absolute;
left: 50%;
top: 50%;
transform: translateZ(0);
backface-visibility: hidden;
-webkit-font-smoothing: subpixel-antialiased;
transform: translate3d(-0%, -0%, 0);
color: #565656;
}
#wordcloud span:nth-child(1) {
animation: letterspacing1 5s infinite alternate;
transition-delay: .1s;
}
#wordcloud span:nth-child(2) {
animation: letterspacing2 5s infinite alternate;
transition-delay: .5s;
}
#wordcloud span:nth-child(3) {
animation: letterspacing3 5s infinite alternate;
transition-delay: 1.04s;
}
#wordcloud span:nth-child(4) {
animation: letterspacing4 5s infinite alternate;
transition-delay: .9s;
}
#wordcloud span:nth-child(5) {
animation: letterspacing5 5s infinite alternate;
transition-delay: .6s;
}
#wordcloud span:nth-child(6) {
animation: letterspacing6 5s infinite alternate;
transition-delay: 1.6s;
}
#wordcloud span:nth-child(7) {
animation: letterspacing7 5s infinite alternate;
transition-delay: .7s;
}
#wordcloud span:nth-child(8) {
animation: letterspacing8 5s infinite alternate;
transition-delay: 1.8s;
}
#wordcloud span:nth-child(9) {
animation: letterspacing9 5s infinite alternate;
transition-delay: 2.3s;
}
#wordcloud span:nth-child(10) {
animation: letterspacing10 5s infinite alternate;
transition-delay: 1s;
}
#keyframes letterspacing1 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing2 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing3 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing4 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing5 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing6 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing7 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing8 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing9 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
#keyframes letterspacing10 {
0% {
opacity: 0;
}
50% {
opacity: 1;
filter: blur(0rem);
}
100% {
opacity: 0;
transform: scale(1.1);
letter-spacing: 2px;
filter: blur(0.2rem);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenMax.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="wordcloud"></div>
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