Animation Stopping In Process - css-animations

** Sorry about previous post. It submitted before I was done and I couldn't edit it. *
I have an image that has two animations. It will first zoom in and then rotate. It works except for when the rotation starts, it jumps to the end in the process. I am new to coding so it probably is an oversight on my part but I would love some help. Code below as well as a fiddle.
HTML
<div class="pageLoad">
<img id ="ox-logo" src="http://demo.alphaomegawebservices.net/weboxsmiles/wp-content/uploads/2014/11/weboxsmiles-logo-600.png">
</div>
CSS
#ox-logo {
position: absolute;
max-width: 50%;
margin-left: 150px;
top: 5%;
z-index: 20;
animation: zoomLogo 3s ease-in 1s, rotateLogo 4s ease-in 1s forwards;
transition: 3s ease-in;
transform-origin: 50% 50%;
-webkit-animation: zoomLogo 3s ease-in 1s, rotateLogo 6s ease-in 1s forwards;
-webkit-transition: 6s ease-in;
-webkit-transform-origin: 50% 50%;
-moz-animation: zoomLogo 3s ease-in 1s, rotateLogo 6s ease-in 1s forwards;
-moz-transition: 3s ease-in;
-moz-transform-origin: 50% 50%;
-o-animation: zoomLogo 3s ease-in 1s, rotateLogo 6s ease-in 1s forwards;
-o-transition: 3s ease-in;
-o-transform-origin: 50% 50%;
-ms-animation: zoomLogo 3s ease-in 1s, rotateLogo 6s ease-in 1s forwards;
-ms-transition: 3s ease-in;
-ms-transform-origin: 50% 50%;
}
#keyframes rotateLogo {
0% {
transform: translate(0px,0px) rotate(0deg) ;
}
100% {
transform: scale(.2) translate(249px,150px) rotate(-720deg);
}
}
#-webkit-keyframes rotateLogo {
0% {
-webkit-transform: translate(0px,0px) rotate(0deg) ;
}
100% {
-webkit-transform: scale(.2) translate(249px,150px) rotate(-720deg);
}
}
#-moz-keyframes rotateLogo {
0% {
-moz-transform: translate(0px,0px) rotate(0deg) ;
}
100% {
-moz-transform: scale(.2) translate(249px,150px) rotate(-720deg);
}
}
#-o-keyframes rotateLogo {
0% {
-o-transform: translate(0px,0px) rotate(0deg) ;
}
100% {
-o-transform: scale(.2) translate(249px,150px) rotate(-720deg);
}
}
#-ms-keyframes rotateLogo {
0% {
-ms-transform: translate(0px,0px) rotate(0deg) ;
}
100% {
-ms-transform: scale(.2) translate(249px,150px) rotate(-720deg);
}
}
#keyframes zoomLogo {
0% {
opacity: 0;
transform: scale(.3);
}
50% {
opacity: 1;
}
}
#-webkit-keyframes zoomLogo {
0% {
opacity: 0;
-webkit-transform: scale(.3);
}
50% {
opacity: 1;
}
}
#-moz-keyframes zoomLogo {
0% {
opacity: 0;
-moz-transform: scale(.3);
}
50% {
opacity: 1;
}
}
#-o-keyframes zoomLogo {
0% {
opacity: 0;
-o-transform: scale(.3);
}
50% {
opacity: 1;
}
}
#-ms-keyframes zoomLogo {
0% {
opacity: 0;
-ms-transform: scale(.3);
}
50% {
opacity: 1;
}
}
FIDDLE
http://jsfiddle.net/SRVIVR/stgb3fdL/51/

Use a single animation instead. Here's a jsfiddle that has only webkit-specific code:
http://jsfiddle.net/stgb3fdL/56/
Code:
#-webkit-keyframes zoomAndRotate {
0% {
opacity: 0;
-webkit-transform: scale(.3);
}
50% {
opacity: 1;
}
51% {
-webkit-transform: translate(0px,0px) rotate(0deg) ;
}
100% {
-webkit-transform: scale(.2) translate(249px,150px) rotate(-720deg);
}
}

Related

why my 3D animation runs smoothly on desktop but not on mobile?

it runs great on desktop but so janky on mobile :( sorry can't show you the result bcs I can't get permission TT_TT basically the animation is about having objects in 3D context of one perspective flying through z-index to your direction (and gets blurry when nearer)
I suspect it might have something to do with moving thousands of pixels? :(
How can I improve performance for mobile? Thanks!
HTML:
`
<template>
<div :class="{'js-loading': !hasLoaded}">
<img class="circle-bg" src="../assets/scene2-coins/circle-big-bg.svg" alt="circle-bg" #load="onImgLoad">
<img class="circle-bg--2" src="../assets/scene2-coins/circle-big-bg.svg" alt="circle-bg--2" #load="onImgLoad">
<img class="coin-silver" src="../assets/scene2-coins/coin-silver.svg" alt="coin-silver" #load="onImgLoad">
<img class="stars" src="../assets/scene2-coins/stars.svg" alt="stars" #load="onImgLoad">
<img class="confetti" src="../assets/scene2-coins/confetti.svg" alt="confetti" #load="onImgLoad">
<img class="confetti--2" src="../assets/scene2-coins/confetti.svg" alt="confetti--2" #load="onImgLoad">
<img class="coin-platinum" src="../assets/scene2-coins/coin-platinum.svg" alt="coin-platinum" #load="onImgLoad">
<img class="coin-gold" src="../assets/scene2-coins/coin-gold.svg" alt="coin-gold" #load="onImgLoad">
<img class="coin-diamond" src="../assets/scene2-coins/coin-diamond.svg" alt="coin-diamond" #load="onImgLoad">
</div>
</template>
`
SCSS:
`
<style lang="scss" scoped>
.js-loading *,
.js-loading *:before,
.js-loading *:after {
animation-play-state: paused !important;
}
div {
display: flex;
justify-content: center;
align-items: center;
perspective: 500px;
perspective-origin: 50% 50%;
img {
position: inherit;
display: block;
}
///////////////////////////// BACKGROUND
.circle-bg {
min-width: 1200px;
min-height: 1200px;
// animation: circle-bg 1000ms linear both 2000ms;
animation-name: circle-bg;
animation-duration: 1000ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes circle-bg {
0% { transform: rotate(180deg) scale3D(.65); }
25% { transform: rotate(180deg) scale3D(.7375); }
50% { transform: rotate(180deg) scale3D(.825); }
75% { transform: rotate(180deg) scale3D(.9125); }
100% { transform: rotate(180deg) scale3D(1); }
}
.circle-bg--2 {
min-width: 1500px;
min-height: 1500px;
// animation: circle-bg--2 1500ms linear both 2000ms;
animation-name: circle-bg--2;
animation-duration: 1500ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes circle-bg--2 {
0% { transform: translate3D(0, 0, -3000px); }
25% { transform: translate3D(0, 0, -2250px); }
50% { transform: translate3D(0, 0, -1500px); }
75% { transform: translate3D(0, 0, -750px); }
100% { transform: translate3D(0, 0, 0px); }
}
///////////////////////////// STARS & CONFETTI
.stars {
// animation: stars 1500ms linear both 2000ms;
animation-name: stars;
animation-duration: 1500ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes stars {
0% { transform: translateZ(-500px); }
100% { transform: translateZ(500px); }
}
.confetti {
width: 50px;
height: 50px;
top: 120px;
left: 250px;
// animation: confetti 1500ms linear both 2000ms;
animation-name: confetti;
animation-duration: 1500ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes confetti {
0% { transform: translateZ(-500px); filter: blur(0px); }
100% { transform: translateZ(500px); filter: blur(2px); }
}
.confetti--2 {
width: 100px;
height: 100px;
top: 480px;
left: 20px;
// animation: confetti--2 1500ms linear both 2000ms;
animation-name: confetti--2;
animation-duration: 1500ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes confetti--2 {
0% { transform: skew(-20deg, 10deg) translateZ(-500px); filter: blur(0px); }
100% { transform: skew(-20deg, 10deg) translateZ(500px); filter: blur(2px); }
}
///////////////////////////// COINS
#mixin all-coins {
width: 100px;
height: 100px;
}
.coin-diamond {
#include all-coins;
top: 330px;
left: 180px;
// animation: coin-diamond 1500ms linear both 2000ms;
animation-name: coin-diamond;
animation-duration: 1500ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes coin-diamond {
0% { transform: rotate(-45deg) translateZ(100px); filter: blur(0px); }
100% { transform: rotate(20deg) translateZ(1100px); filter: blur(5px); }
}
.coin-gold {
#include all-coins;
top: 300px;
left: 50px;
// animation: coin-gold 1500ms linear both 2000ms;
animation-name: coin-gold;
animation-duration: 1500ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes coin-gold {
0% { transform: rotate(20deg) translateZ(-100px); filter: blur(0px); }
100% { transform: rotate(-40deg) translateZ(900px); filter: blur(4px); }
}
.coin-platinum {
#include all-coins;
top: 220px;
left: 200px;
// animation: coin-platinum 1500ms linear both 2000ms;
animation-name: coin-platinum;
animation-duration: 1500ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes coin-platinum {
0% { transform: rotate(20deg) translateZ(-300px); filter: blur(0px); }
100% { transform: rotate(60deg) translateZ(700px); filter: blur(3px); }
}
.coin-silver {
#include all-coins;
top: 180px;
left: 50px;
// animation: coin-silver 1500ms linear both 2000ms;
animation-name: coin-silver;
animation-duration: 1500ms;
animation-timing-function: linear;
animation-delay: 2000ms;
animation-iteration-count: 1;
animation-direction: normal;
animation-fill-mode: both;
}
#keyframes coin-silver {
0% { transform: rotate(0deg) translateZ(-500px); filter: blur(0px); }
100% { transform: rotate(60deg) translateZ(500px); filter: blur(2px); }
}
}
</style>
`
I've tried to optimize by adding several trick code:
display block on all
not using shorthand animation
using class animation paused until img #load is true
have tried to use will-change, but later deleted it since somebody said it's better to be used in JS - now using translate3D and scale3D (on some, haven't changed the rest of the code)
using more than 2 keyframes (on some, haven't changed the rest of the code)
btw all assets are compressed under 100kb
I suspect is the blur animation, filter blur is a GPU destroyer when you abuse of that. Hope it helps!

set an element initially hidden and stay visible after finishing animation

in the example below:
wrap should be initially hidden
after one second - in should be outside of page
next second - it should go into page
finishing animation - it should stay visible - and here is the problem - it goes hidden
If I remove visibility:hidden at start - it is visible the first second - that's not allowed
how to do this ?
.wrap{
visibility:hidden; width:54px; height:54px; background:orange;
}
.wrap{animation: wrap 1s; animation-delay:1s}
#keyframes wrap{
0% {transform: translateX(-300px); visibility:visible}
100% {transform: translateX(0);}
}
<div class='wrap'></div>
This is happens, when the animation finished, the swap class gets its initial value from itself. To solve this you need add in the last keyframe (100%) visibility: visible; and also add animation-fill-mode: forwards; to stop the animation on the last keyframe.
.wrap {
visibility: hidden;
width: 54px;
height: 54px;
background: orange;
}
.wrap {
animation: wrap 1s;
animation-delay: 1s;
animation-fill-mode: forwards; /* new line */
}
#keyframes wrap {
0% {
transform: translateX(-300px);
visibility: visible;
}
100% {
transform: translateX(0);
visibility: visible; /* new line */
}
}
.wrap {
visibility: hidden;
width: 54px;
height: 54px;
background: orange;
}
.wrap {
animation: wrap 1s;
animation-delay: 1s;
animation-fill-mode: forwards; /* new line */
}
#keyframes wrap {
0% {
transform: translateX(-300px);
visibility: visible;
}
100% {
transform: translateX(0);
visibility: visible; /* new line */
}
}
<div class="wrap"></div>

Nuxt scroll up before page transition

I have created a transition to be run between route changes:
.page-enter-active {
position: absolute;
width: 100%;
//max-height: 100vh;
overflow: hidden;
animation: slideScaleRight 2s ease;
}
.page-leave-active {
position: absolute;
width: 100%;
//max-height: 100vh;
overflow: hidden;
animation: scaleSlideRight 2s ease;
}
#keyframes scaleSlideRight {
0% {
transform: scale(1);
}
33% {
transform: scale(0.75) translateX(0);
opacity: 0.5;
}
66% {
transform: scale(0.75) translateX(150%);
}
100% {
transform: scale(0.75) translateX(150%);
}
}
#keyframes slideScaleRight {
0% {
transform: scale(0.75) translateX(-150%);
}
33% {
transform: scale(0.75) translateX(-150%);
}
66% {
opacity: 0.5;
transform: scale(0.75) translateX(0);
}
100% {
transform: scale(1) translateX(0);
}
}
The transition run smooth but I just discover that if the page is not at top position, before leaving, nuxt force an scroll to the top making the experience really bad...
I can guess nuxt is scrolling up before triggering the transition and I really would like to keep the page where it is before leaving.
Any ideas?
You could set scrollToTop: false on an upper page (or even in /layouts/default.vue?) to prevent the scrolling of the page as shown in the documentation.
If you want more granularity, you could also look into scrollBehavior.

I want to create a custom loader in ionic 4 ,but in the message feild it is showing html code ,but not rendering my gif image

async presentLoading() {
const loading = await this.loader.create({
duration: 2000,
showBackdrop:false,
cssClass:'sa',
spinner:'false',
message:`
<div class="custom-spinner-container">
<img class="loading" width="120px" height="120px" src="assets/loader1.gif" />
</div>`
});
return await loading.present();
}
You can just simply achieve it with css
//Header of file
import { LoadingController } from "#ionic/angular";
//In the constructor
constructor(public loadingCtrl: LoadingController) {
}
async showLoader () {
this.loader = await this.loadingCtrl.create({
cssClass: 'custom-loader',
spinner: null
});
await this.loader.present();
}
/* Inside global.scss
You can create amazing gifs with
https://loading.io/animation
*/
.custom-loader {
--background: transparent;
ion-backdrop {
background-color: #fff;
opacity: .9 !important;
}
.loading-wrapper {
-webkit-animation: ld-vortex-out 2s ease-out infinite;
animation: ld-vortex-out 2s ease-out infinite;
animation-timing-function: cubic-bezier(0.05, 0, 3, 0.05);
background-image: url("/assets/img/baubap-logo-circle.svg");
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
min-width: 90px;
min-height: 90px;
box-shadow: none;
-webkit-box-shadow: none;
}
}
#keyframes ld-vortex-out {
0% {
-webkit-transform: rotate(0deg) scale(0);
transform: rotate(0deg) scale(0);
opacity: 1;
}
60% {
-webkit-transform: rotate(1800deg) scale(1);
transform: rotate(1800deg) scale(1);
opacity: 1;
}
100% {
-webkit-transform: rotate(1800deg) scale(1);
transform: rotate(1800deg) scale(1);
opacity: 0;
}
}
#-webkit-keyframes ld-vortex-out {
0% {
-webkit-transform: rotate(0deg) scale(0);
transform: rotate(0deg) scale(0);
opacity: 1;
}
60% {
-webkit-transform: rotate(1800deg) scale(1);
transform: rotate(1800deg) scale(1);
opacity: 1;
}
100% {
-webkit-transform: rotate(1800deg) scale(1);
transform: rotate(1800deg) scale(1);
opacity: 0;
}
}
Result
Baubap loader screen
So did you check documentation?
In Ionic 3 it was a different syntax and it was not supposed to change:
https://ionicframework.com/docs/api/components/loading/LoadingController/
See their example - use different value for hiding default spinner...
Try this:
async presentLoading() {
const loading = await this.loader.create({
duration: 2000,
showBackdrop:false,
cssClass:'sa',
spinner:'hide',
message:`
<div class="custom-spinner-container">
<img class="loading" width="120px" height="120px" src="assets/loader1.gif" />
</div>`
});
return await loading.present();
}
Update: seems like in Ionic 4 suggested way to deal with loader animation is via ion-spinner. But its unclear if the old way should break or is just not supported yet in Beta

css3animation + box-shadow not working in Safari & Opera

I have implemented box-shadow effect in an div using CSS3 Animation... The code works fine in firefox and chrome but i dont know why my code is not working in Safari and Opera...
Safari Version i am using 5.1.7...
and Opera Version 12.12...
JsFiddle Link
My Code:
#-moz-keyframes glowz {
0% { -moz-box-shadow:0px 0px 10px 10px rgba(64,142,0,1); }
33% { -moz-box-shadow:0px 0px 7px 7px rgba(64,142,0,1); }
66% { -moz-box-shadow:0px 0px 2px 2px rgba(64,142,0,1); }
100% { -moz-box-shadow:0px 0px 9px 9px rgba(64,142,0,1); }
}
#-webkit-keyframes glowz {
0% { -webkit-box-shadow:0px 0px 10px 10px rgba(64,142,0,1); }
33% { -webkit-box-shadow:0px 0px 7px 7px rgba(64,142,0,1); }
66% { -webkit-box-shadow:0px 0px 2px 2px rgba(64,142,0,1); }
100% { -webkit-box-shadow:0px 0px 9px 9px rgba(64,142,0,1); }
}
#-o-keyframes glowz {
0% { -o-box-shadow:0px 0px 10px 10px rgba(64,142,0,1); }
33% { -o-box-shadow:0px 0px 7px 7px rgba(64,142,0,1); }
66% { -o-box-shadow:0px 0px 2px 2px rgba(64,142,0,1); }
100% { -o-box-shadow:0px 0px 9px 9px rgba(64,142,0,1); }
}
#keyframes glowz {
0% { box-shadow:0px 0px 10px 10px rgba(64,142,0,1); }
33% { box-shadow:0px 0px 7px 7px rgba(64,142,0,1); }
66% { box-shadow:0px 0px 2px 2px rgba(64,142,0,1); }
100% { box-shadow:0px 0px 9px 9px rgba(64,142,0,1); }
}
.blinker {
background-color: #FF0000;
display: block;
height: 27px;
position: absolute;
width: 27px;
left:50%; top:50%;
border-radius: 5em; -webkit-border-radius: 5em; -moz-border-radius: 5em; -o-border-radius: 5em;
-ms-animation: 5s ease-in-out 0s alternate none infinite glowz;
-webkit-animation: 5s ease-in-out 0s alternate none infinite glowz;
-moz-animation: 5s ease-in-out 0s alternate none infinite glowz;
-o-animation: 5s ease-in-out 0s alternate none infinite glowz;
animation: 5s ease-in-out 0s alternate none infinite glowz;
}
Is css3 animation is buggy in safari and opera ??
Tweak your CSS little bit and it will work.
Replace Following code:
-ms-animation: 5s ease-in-out 0s alternate none infinite glowz;
-webkit-animation: 5s ease-in-out 0s alternate none infinite glowz;
-moz-animation: 5s ease-in-out 0s alternate none infinite glowz;
-o-animation: 5s ease-in-out 0s alternate none infinite glowz;
animation: 5s ease-in-out 0s alternate none infinite glowz;
With following Code:
-webkit-animation-name: glowz;
-webkit-animation-duration: 5s;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-webkit-animation-direction: alternate;
-webkit-animation-delay: 0;
-webkit-animation-fill-mode: none;
-moz-animation-name: glowz;
-moz-animation-duration: 5s;
-moz-animation-timing-function: ease-in-out;
-moz-animation-iteration-count: infinite;
-moz-animation-direction: alternate;
-moz-animation-delay: 0;
-moz-animation-fill-mode: none;
-o-animation-name: glowz;
-o-animation-duration: 5s;
-o-animation-timing-function: ease-in-out;
-o-animation-iteration-count: infinite;
-o-animation-direction: alternate;
-o-animation-delay: 0;
-o-animation-fill-mode: none;
animation-name: glowz;
animation-duration: 5s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-delay: 0;
animation-fill-mode: none;
DEMO