I've made a simple animation I want to use as a pre-loader for my website using CSS animations.
It seems to work beautifully on everything except iOS devices, where the separate elements seem to fire out of sync and end up just doing their own thing.
You can see the fiddle and try it own on your phone here
UPDATE:
Weird – so the JSfiddle seems to work fine on iOS but when the same code comes into practice live on my site it seems to mess things up? you can see it here
Makes me think its actually something to do with my pre-loading script?
$(window).load(function() { // makes sure the whole site is loaded
$('#status').fadeOut(); // will first fade out the loading animation
$('#preloader').delay(350).fadeOut(300); // will fade out the white DIV that covers the website.
$('body').delay(350).css({'overflow':'visible'});
})
CSS
.square {
background: #61CAFF;
width: 150px;
height: 150px;
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
-webkit-animation: shrinkgrow 3s ease-in-out infinite;
animation: shrinkgrow 3s ease-in-out infinite;
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
.circle {
background: #9DFDC3;
width: 150px;
height: 150px;
border-radius: 50%;
-webkit-animation: shrinkgrow 3s ease-in-out infinite;
animation: shrinkgrow 3s ease-in-out infinite;
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.triangle {
width: 0;
height: 0;
border-style: solid;
border-width: 0 80px 140px 80px;
border-color: transparent transparent #F896D5 transparent;
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
-webkit-animation: shrinkgrow 3s ease-in-out infinite;
animation: shrinkgrow 3s ease-in-out infinite;
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
#-webkit-keyframes shrinkgrow {
0% {
-webkit-transform: scale(0);
transform: scale(0);
}
12.5% {
-webkit-transform: scale(1);
transform: scale(1);
}
25% {
-webkit-transform: scale(1);
transform: scale(1);
}
33% {
-webkit-transform: scale(0);
transform: scale(0);
}
100% {
-webkit-transform: scale(0);
transform: scale(0);
}
}
#keyframes shrinkgrow {
0% {
-webkit-transform: scale(0);
transform: scale(0);
}
12.5% {
-webkit-transform: scale(1);
transform: scale(1);
}
25% {
-webkit-transform: scale(1);
transform: scale(1);
}
33% {
-webkit-transform: scale(0);
transform: scale(0);
}
100% {
-webkit-transform: scale(0);
transform: scale(0);
}
}
Related
I have been struggling with this for quite a bit now.
.intro #intro-n,
.intro #intro-o,
.intro #intro-a2 {
stroke-dasharray: 400;
stroke-dashoffset: 400; }
.intro #intro-n {
/*-webkit-animation: intro-letters 0.9s linear;*/
-webkit-animation-name: intro-letters;
-webkit-animation-duration: 0.9s;
-webkit-animation-timing-function: linear;
-moz-animation: intro-letters 0.9s linear;
animation: intro-letters 0.9s linear;
animation-name: intro-letters;
animation-duration: 0.9s;
animation-timing-function: linear;
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-delay: 0s;
-moz-animation-delay: 0s;
animation-delay: 0s; }
#-webkit-keyframes intro-letters {
0% {
}
100% {
stroke-dashoffset: 0; } }
#-moz-keyframes intro-letters {
0% {
}
100% {
stroke-dashoffset: 0; } }
#keyframes intro-letters {
0% {
}
100% {
stroke-dashoffset: 0; } }
http://codepen.io/anon/pen/ORkZwG
This code perfectly works on Windows(except IE) and Android devices, but when i try to launch it in iOS safari or even chrome SVG animations are blank.
Edit:
Yes, it works in iOS desktop Google Chrome version, but it doesn't work on iOS Tablet Chrome nor Safari
After spending a fair amount of time on this issue, I finally cracked it down, it seems that the issue was in this bit of code:
.intro svg {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%);
-webkit-transform: translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
-o-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
width: 100%;
max-width: 250px;
/*-webkit-animation: intro-hide-element 0s linear;*/
-webkit-animation-name: intro-hide-element;
-webkit-animation-duration: 0s;
-webkit-animation-timing-function: linear;
-moz-animation: intro-hide-element 0s linear;
animation: intro-hide-element 0s linear;
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-delay: 5.1s;
-moz-animation-delay: 5.1s;
animation-delay: 5.1s; }
Particularly here:
-webkit-animation-duration: 0s;
-moz-animation: intro-hide-element 0s linear;
animation: intro-hide-element 0s linear;
Where after changing it to:
-webkit-animation-duration: 0.001s;
-moz-animation: intro-hide-element 0.001s linear;
animation: intro-hide-element 0.001s linear;
The animations in safari tablet browser appeared, I'm not entirely sure why it works in chrome and not safari, but that was what did the trick for me, hopefully someone can explain a bit more in detail why this is happening but in the mean time hope it helps someone.
I am trying to override the default animation for UIBModal. However this is not working. The default animation runs only.
.modal.modal-slide-in-right .modal-dialog {
opacity: 0;
-webkit-transform: translate(20%, 0%);
-ms-transform: translate(20%, 0%);
-o-transform: translate(20%, 0%);
transform: translate(20%, 0%);
-webkit-transition: all .3s cubic-bezier(.25, .5, .5, .9) 1s;
-o-transition: all .3s cubic-bezier(.25, .5, .5, .9) 1s;
transition: all .3s cubic-bezier(.25, .5, .5, .9) 1s;
}
.modal.modal-slide-in-right.in .modal-dialog {
opacity: 1;
-webkit-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
transform: translate(0px, 0px);
}
http://plnkr.co/edit/YQ0eHIWrHlm90oW5oS4r?p=preview
You forget to insert your extra.css stylesheet into the index.html
<link rel="stylesheet" href="extra.css">
Here is a working plunk
This code works well on Mozilla Firefox, Google Chrome, and MS explorer. However, it doesn't work at all on mobile devices, particularly iOS. Please let me know what needs to be added or removed to make it function properly.
HTML
<div class="bg-grad">
<div class="clouds">
<div class="cloud x1"></div>
</div>
</div>
CSS
/* BG Gradients
~-----------------------------------------*/
.bg-grad {
background: #000;
background: transparent url("http://www.freelargeimages.com/wp-content/uploads/2014/12/Landscape_01.jpg") center bottom no-repeat;
-moz-background-size: cover;
-o-background-size: cover;
-webkit-background-size: cover;
background-size: cover;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.bg-grad .bg-layer {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0;
z-index: 6;
-moz-transition: opacity 0.5s ease;
-o-transition: opacity 0.5s ease;
-webkit-transition: opacity 0.5s ease;
transition: opacity 0.5s ease;
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.bg-grad .bg-layer.on {
opacity: 1;
}
/* Clouds
~-----------------------------------------*/
.cloud {
width: 100%;
height: 900px;
position: relative;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 5;
background: transparent url('http://freepngimages.com/wp-content/uploads/2014/11/ten-party-balloons.png') left bottom no-repeat;
-moz-background-size: cover;
-o-background-size: cover;
-webkit-background-size: cover;
background-size: cover;
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
#media (max-width: 550px) {
.cloud {
display: none;
}
}
.x1 {
-moz-animation: moveclouds 40s linear infinite;
-webkit-animation: moveclouds 40s linear infinite;
animation: moveclouds 40s linear infinite;
width: 2036px;
height: 1608px;
}
#-webkit-keyframes moveclouds {
0% {
margin-left: 100%;
}
100% {
margin-left: -1400px;
}
}
#-moz-keyframes moveclouds {
0% {
margin-left: 100%;
}
100% {
margin-left: -1400px;
}
}
#-o-keyframes moveclouds {
0% {
margin-left: 100%;
}
100% {
margin-left: -1400px;
}
}
https://jsfiddle.net/r2uuvubg/2/
Can anybody tell why this CSS3 Animation refuses to work when I test it on my Iphone? It works fine on Chrome.
.heartbeat:after {
content: "\f118";
font-family: fontAwesome;
font-size: 50px;
color: rgb(0, 156, 255);
-webkit-animation: spin 1000ms ease 0s infinite normal;
-moz-animation: spin 1000ms ease 0s infinite normal;
-ms-animation: spin 1000ms ease 0s infinite normal;
-o-animation: spin 1000ms ease 0s infinite normal;
animation: spin 1000ms ease 0s infinite normal;
}
#-ms-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#-moz-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#-webkit-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
I checked similar questions and tried to replace from and to with 0% and 100%, and rotate 180 degrees at a time, use rotate3d instead; didnt work.
There is a reason behind this. You have an error here:
#-ms-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#-moz-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#-webkit-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
Notice anything here, for example?
#-moz-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
You're using a -moz- keyframe, which is fine, but notice anything else?
How about the -webkit- prefix on the transform?
So, in essence, this would become:
#-moz-keyframes spin {
from { -moz-transform: rotate(0deg); }
to { -moz-transform: rotate(360deg); }
}
Repeat this for your other keyframes and this should sort out a problem or two...
I'm not even sure what else to try. I've even put it through a CSS validator and it passes. Works in Chrome and Firefox. Safari shows no warnings or errors that I can tell.
Relevant CSS:
.lines {
width: 32px;
margin: 20px auto;
}
.line-bar {
display: inline-block;
background-color: #f7f7f7;
width: 4px;
height: 18px;
border-radius: 4px;
-webkit-animation: loading 1s ease-in-out infinite;
animation: loading 1s ease-in-out infinite;
}
.line-bar:nth-child(1) {
}
.line-bar:nth-child(2) {
-webkit-animation-delay: 0.09s;
animation-delay: 0.09s;
}
.line-bar:nth-child(3) {
-webkit-animation-delay: 0.18s;
animation-delay: 0.18s;
}
.line-bar:nth-child(4) {
-webkit-animation-delay: 0.27s;
animation-delay: 0.27s;
}
#-webkit-keyframes loading {
0% {
transform: scale(1);
}
20% {
transform: scale(1, 2.2);
}
40% {
transform: scale(1);
}
}
#keyframes loading {
0% {
transform: scale(1);
}
20% {
transform: scale(1, 2.2);
}
40% {
transform: scale(1);
}
}
http://jsbin.com/yobatuveji/1
You need to use webkit- vendor prefix also on the transform property
#-webkit-keyframes loading {
0% {
-webkit-transform: scale(1);
}
20% {
-webkit-transform: scale(1, 2.2);
}
40% {
-webkit-transform: scale(1);
}
}
Since these keyframes are introduced by the -webkit- prefix.
With this change the animation runs as expected also on Safari (just checked on v.7.1.2/MacOs).