This is from the .less file that comes with the npm package rc-slider (React Slider) https://github.com/react-component/slider/blob/master/src/Range.jsx
Examples of the slider: http://react-component.github.io/slider/examples/range.html
The error
205 | .#{className}-enter, .#{className}-appear {
.motion-common() {
animation-duration: .3s;
animation-fill-mode: both;
display: block !important;
}
.make-motion(#className, #keyframeName) {
.#{className}-enter, .#{className}-appear {
.motion-common();
animation-play-state: paused;
}
.#{className}-leave {
.motion-common();
animation-play-state: paused;
}
.#{className}-enter.#{className}-enter-active, .#{className}-appear.#{className}-appear-active {
animation-name: ~"#{keyframeName}In";
animation-play-state: running;
}
.#{className}-leave.#{className}-leave-active {
animation-name: ~"#{keyframeName}Out";
animation-play-state: running;
}
}
.zoom-motion(#className, #keyframeName) {
.make-motion(#className, #keyframeName);
.#{className}-enter, .#{className}-appear {
transform: scale(0, 0); // need this by yiminghe
animation-timing-function: #ease-out-quint;
}
.#{className}-leave {
animation-timing-function: #ease-in-quint;
}
}
.zoom-motion(rc-slider-tooltip-zoom-down, rcSliderTooltipZoomDown);
#keyframes rcSliderTooltipZoomDownIn {
0% {
opacity: 0;
transform-origin: 50% 100%;
transform: scale(0, 0);
}
100% {
transform-origin: 50% 100%;
transform: scale(1, 1);
}
}
#keyframes rcSliderTooltipZoomDownOut {
0% {
transform-origin: 50% 100%;
transform: scale(1, 1);
}
100% {
opacity: 0;
transform-origin: 50% 100%;
transform: scale(0, 0);
}
}
Ah I got this to work, so far only some minor lint errors on naming convention, but it's not breaking now :)
#motion-common() {
animation-duration: .3s;
animation-fill-mode: both;
display: block !important;
}
#make-motion($className, $keyframeName) {
$className {
&-enter, &-appear {
#motion-common();
animation-play-state: paused;
}
&-leave {
#motion-common();
animation-play-state: paused;
}
&-enter.&-enter-active,
&-appear.&-appear-active {
animation-name: ~"${keyframeName}In";
animation-play-state: running;
}
&-leave.&-leave-active {
animation-name: ~"${keyframeName}Out";
animation-play-state: running;
}
}
}
#zoom-motion($className, $keyframeName) {
#make-motion($className, $keyframeName);
$className {
&-enter, &-appear {
transform: scale(0, 0); // need this by yiminghe
animation-timing-function: $ease-out-quint;
}
&-leave {
animation-timing-function: $ease-in-quint;
}
}
}
#zoom-motion(rc-slider-tooltip-zoom-down, rcSliderTooltipZoomDown);
#keyframes rcSliderTooltipZoomDownIn {
0% {
opacity: 0;
transform-origin: 50% 100%;
transform: scale(0, 0);
}
100% {
transform-origin: 50% 100%;
transform: scale(1, 1);
}
}
#keyframes rcSliderTooltipZoomDownOut {
0% {
transform-origin: 50% 100%;
transform: scale(1, 1);
}
100% {
opacity: 0;
transform-origin: 50% 100%;
transform: scale(0, 0);
}
}
Related
I know this question has been asked many times but my animation is different.
I gave multiple animations to one element using delay. Animation works perfect on all browsers except Safari.
Apparently, Safari wants the animation to be reversed. I tried this but failed. This is some lines of the code to show how I write the animation.
//first revealed text
.has-line-anim-hidden-first {
animation-name: lineScaleOut, lineToBottom, lineToTop, lineScale;
animation-duration: $duration, $duration, $duration, $duration;
animation-delay: 1.6s, 1.9s, 3.6s, 3.9s;
animation-fill-mode: both, both, both, forwards;
animation-timing-function: ease-out, ease-out, ease-out, ease-out;
}
Keyframes:
//Mixin
#mixin keyframes ( $animation-name ) {
#-webkit-keyframes #{$animation-name} {
#content;
}
#-moz-keyframes #{$animation-name} {
#content;
}
#-o-keyframes #{$animation-name} {
#content;
}
#keyframes #{$animation-name} {
#content;
}
}
#include keyframes(reveal) {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#include keyframes(unreveal) {
to {
opacity: 0;
}
}
#include keyframes(lineToTop) {
to {
bottom: 80%;
}
}
#include keyframes(lineToBottom) {
from {
bottom: 80%;
}
to {
bottom: 0%;
}
}
#include keyframes(lineScale) {
from {
width: 100%;
}
to {
width: 0;
}
}
#include keyframes(lineScaleOut) {
from {
width: 0;
opacity: 0
}
to {
width: 100%;
opacity: 1;
}
}
You can check all my code by clicking this
What do I need to do to make the code work on the Safari?
I am rotating some words (for some grammar rules) and some of you already nicely helped me tighten up the thing. I would however like to speed up the animation/fade even more to avoid the words overlapping one another. Also how would I go about adding another 10 words without messing up the fade?
Here is my
HTML:
<span>The boy
<div class="rw-words rw-words-1">
<span>see<b>s</b></span>
<span>want<b>s</b></span>
<span>use<b>s</b></span>
<span>find<b>s</b></span>
<span>need<b>s</b></span>
<span>trie<b>s</b></span>
<span>love<b>s</b></span>
<span>leave<b>s</b></span>
<span>call<b>s</b></span>
<span>work<b>s</b></span>
</div><span id="girlWord">the girl.</span><br><br>
And the CSS - I have trouble understanding the animation. I understand the delays that cause the words to appear, but I don't understand where the actual fade is and which part is in/out.
./*/
ROTATING WORDS
/*/
.rw-words{
display: inline;
text-indent: 10px;
}
#girlWord {
margin-left: 4em; /* <-- Add space for the animated words */
}
.rw-words span{
position: absolute;
opacity: 0;
overflow: hidden;
width: auto;
color: #0f269e;
}
.rw-words-1 span{
-webkit-animation: rotateWordsFirst 20s linear infinite 0s;
-ms-animation: rotateWordsFirst 20s linear infinite 0s;
animation: rotateWordsFirst 20s linear infinite 0s;
}
}
.rw-words span:nth-child(1) {
-webkit-animation-delay: 0s;
-ms-animation-delay: 0s;
animation-delay: 0s;
color: #0f269e;
}
.rw-words span:nth-child(2) {
-webkit-animation-delay: 2s;
-ms-animation-delay: 2s;
animation-delay: 2s;
color: #0f269e;
}
.rw-words span:nth-child(3) {
-webkit-animation-delay: 4s;
-ms-animation-delay: 4s;
animation-delay: 4s;
color: #0f269e;
}
.rw-words span:nth-child(4) {
-webkit-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
color: #0f269e;
}
.rw-words span:nth-child(5) {
-webkit-animation-delay: 8s;
-ms-animation-delay: 8s;
animation-delay: 8s;
color: #0f269e;
}
.rw-words span:nth-child(6) {
-webkit-animation-delay: 10s;
-ms-animation-delay: 10s;
animation-delay: 10s;
color: #0f269e;
}
.rw-words span:nth-child(7) {
-webkit-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
color: #0f269e;
}
.rw-words span:nth-child(8) {
-webkit-animation-delay: 14s;
-ms-animation-delay: 14s;
animation-delay: 14s;
color: #0f269e;
}
.rw-words span:nth-child(9) {
-webkit-animation-delay: 16s;
-ms-animation-delay: 16s;
animation-delay: 16s;
color: #0f269e;
}
.rw-words span:nth-child(10) {
-webkit-animation-delay: 18s;
-ms-animation-delay: 18s;
animation-delay: 18s;
color: #0f269e;
}
}
#-webkit-keyframes rotateWordsFirst {
0% { opacity: 1; -webkit-animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#-ms-keyframes rotateWordsFirst {
0% { opacity: 1; -ms-animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#keyframes rotateWordsFirst {
0% { opacity: 1; -webkit-animation-timing-function: linear; animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 0; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#media screen and (max-width: 768px){
.rw-sentence { font-size: 18px; }
}
#media screen and (max-width: 320px)
Here is jsfiddle.
https://jsfiddle.net/rh98fsom/
I am not an expert, but I believe you can keep adding these and just increase each one by 2 as you have above. interested to see if anyone else has some input. this part you can condense by putting them together, and now you can see where your animation fade in/out occurs:
/*enter code here*/
.rw-words span:nth-child(# ...) {
/*enter code here*/
#keyframes rotateWords {
0% {
opacity: 0 ;
}
8% {
opacity: 1 ;
-webkit-animation-timing-function: ease-in;
-moz-animation-timing-function: ease-in;
-o-animation-timing-function: ease-in;
-ms-animation-timing-function: ease-in;
animation-timing-function: ease-in;
}
19% {
opacity: 1;
}
25% {
opacity: 0;
}
100% {
opacity: 0;
}
}
I am trying these SCSS mixins from this gist for CSS animation browser prefixes, but it's outputting the literal $animation_name where it should be outputting the actual value for $animation_name in the CSS. How do I get the actual value into the CSS output?
SCSS:
#mixin animation ($delay, $duration, $animation) {
-webkit-animation-delay: $delay;
-webkit-animation-duration: $duration;
-webkit-animation-name: $animation;
-webkit-animation-fill-mode: forwards;
-moz-animation-delay: $delay;
-moz-animation-duration: $duration;
-moz-animation-name: $animation;
-moz-animation-fill-mode: forwards;
-o-animation-delay: $delay;
-o-animation-duration: $duration;
-o-animation-name: $animation;
-o-animation-fill-mode: forwards;
animation-delay: $delay;
animation-duration: $duration;
animation-name: $animation;
animation-fill-mode: forwards;
}
#mixin mykeyframe ($animation_name) {
#-webkit-keyframes $animation_name {
#content;
}
#-moz-keyframes $animation_name {
#content;
}
#-o-keyframes $animation_name {
#content;
}
#keyframes $animation_name {
#content;
}
}
.top{
position:relative;
top: 0%;
width: 100%;
text-align: center;
#include animation(0s,1s,inFromTop);
}
#include mykeyframe(inFromTop) {
from{
margin-top: -100%;
}
to{
margin-top: 0;
}
}
CSS output (note the literal $animation_name in the code)
.top {
position: relative;
top: 0%;
width: 100%;
text-align: center;
-webkit-animation-delay: 0s;
-webkit-animation-duration: 1s;
-webkit-animation-name: inFromTop;
-webkit-animation-fill-mode: forwards;
-moz-animation-delay: 0s;
-moz-animation-duration: 1s;
-moz-animation-name: inFromTop;
-moz-animation-fill-mode: forwards;
-o-animation-delay: 0s;
-o-animation-duration: 1s;
-o-animation-name: inFromTop;
-o-animation-fill-mode: forwards;
animation-delay: 0s;
animation-duration: 1s;
animation-name: inFromTop;
animation-fill-mode: forwards;
}
#-webkit-keyframes $animation_name {
from {
margin-top: -100%;
}
to {
margin-top: 0;
}
}
#-moz-keyframes $animation_name {
from {
margin-top: -100%;
}
to {
margin-top: 0;
}
}
#-o-keyframes $animation_name {
from {
margin-top: -100%;
}
to {
margin-top: 0;
}
}
#keyframes $animation_name {
from {
margin-top: -100%;
}
to {
margin-top: 0;
}
}
Here's the HTML and SCSS in Codepen
Inspect the CSS in Codepen debug mode to see the CSS it is outputting
Sass interpolation seems to solve the issue: SassMeister Demo
SCSS:
#mixin mykeyframe ($animation_name) {
#-webkit-keyframes #{$animation_name} {
#content;
}
#-moz-keyframes #{$animation_name} {
#content;
}
#-o-keyframes #{$animation_name} {
#content;
}
#keyframes #{$animation_name} {
#content;
}
}
CSS Output:
#-webkit-keyframes inFromTop {
from {
margin-top: -100%;
}
to {
margin-top: 0;
}
}
#-moz-keyframes inFromTop {
from {
margin-top: -100%;
}
to {
margin-top: 0;
}
}
#-o-keyframes inFromTop {
from {
margin-top: -100%;
}
to {
margin-top: 0;
}
}
#keyframes inFromTop {
from {
margin-top: -100%;
}
to {
margin-top: 0;
}
}
I want to create mixin/function in sass that will customize my #keyframes animation. It looks like I can do it using this code, but is there a better way?
https://www.sassmeister.com/gist/13a4b5d4df15ca46bd484ab5758f6de0
$animation-name: 1 !global;
#mixin animate_bg($color1, $color2) {
$animation-name: unique-id() !global;
#keyframes #{$animation-name} {
0% {
background-color: $color1;
}
100% {
background-color: $color2;
}
}
#content
}
#include animate_bg(#007efe, #cce5ff) {
a.finished {
animation-duration: 0.25s;
animation-name: $animation-name;
}
}
#include animate_bg(#aabbcc, #ffaabb) {
b.finished {
animation-duration: 0.25s;
animation-name: $animation-name;
}
}
Produces this css
#keyframes uz61m5wd4 {
0% {
background-color: #007efe;
}
100% {
background-color: #cce5ff;
}
}
a.finished {
animation-duration: 0.25s;
animation-name: uz61m5wd4;
}
#keyframes uz61m5wdd {
0% {
background-color: #aabbcc;
}
100% {
background-color: #ffaabb;
}
}
b.finished {
animation-duration: 0.25s;
animation-name: uz61m5wdd;
}
Shrunk the SCSS slightly by including your .finished class in the mixin. Not sure if this is exactly what you were looking for, though.
// mixin:
#mixin animate_bg($color1, $color2, $class, $duration) {
$animation-name: unique-id() !global;
#keyframes #{$animation-name} {
0% {
background-color: $color1;
}
100% {
background-color: $color2;
}
}
.#{$class}.finished {
animation-duration: $duration;
animation-name: $animation-name;
}
}
// using the mixin:
#include animate_bg(#007efe, #cce5ff, a, .25s);
#include animate_bg(#aabbcc, #ffaabb, b, .25s);
I made some CSS animations, and on WebKit (Safari/Chrome), it works fine, but on Firefox the timing is messed up.
JSFiddle: http://jsfiddle.net/jmorais/p5XCD/1/
Code:
var open = false;
var intransition = false;
function openCard() {
intransition = true;
$('.out').addClass('openingOut');
$('.in-left').addClass('openingIn');
setTimeout(function() {
$('.out').css("z-index", "2");
$('.in-left').css("z-index", "3");
}, 850);
setTimeout(function(){
$('.out').removeClass('openingOut').addClass('outOpen');
$('.in-left').removeClass('openingIn').addClass('inOpen');
open = true;
intransition = false;
}, 3000);
}
function closeCard() {
intransition = true;
$('.out').addClass('closingOut');
$('.in-left').addClass('closingIn');
setTimeout(function() {
$('.out').css("z-index", "3");
$('.in-left').css("z-index", "2");
}, 1000);
setTimeout(function(){
$('.out').removeClass('closingOut').removeClass('outOpen');
$('.in-left').removeClass('closingIn').removeClass('inOpen');
open = false;
intransition = false;
}, 3000);
}
function toggleCard() {
if (intransition) { return; }
if (open) {
closeCard();
} else {
openCard();
}
}
body {
margin-left: 350px;
}
.tile {
position:absolute;
width:350px;
height:400px;
left: 50%;
margin: 0 auto;
background: pink;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
.out {
z-index: 3;
}
.in-left {
z-index: 2;
left: -350px;
-webkit-transform: rotateY(-180deg);
-webkit-transform-origin: 100% 100%;
-moz-transform: rotateY(-180deg);
-moz-transform-origin: 100% 100%;
}
.in-right {
z-index: -1;
}
.content {
border: 3px black double;
margin: 10px;
padding: 20px;
height: 335px;
}
.perspective {
-webkit-perspective: 1200px;
-moz-perspective: 1200px;
position: relative;
display: inline-block;
}
/*****************************************
* Open
******************************************/
.openingOut {
/* Webkit */
-webkit-animation-name: open-card-out;
-webkit-animation-timing-function: ease;
-webkit-animation-duration: 3s;
-webkit-transition-delay: 0s;
-webkit-animation-iteration-count: 1;
-webkit-animation-direction: alternate;
/* Firefox */
-moz-animation-name: open-card-out;
-moz-animation-timing-function: ease;
-moz-animation-duration: 3s;
-moz-transition-delay: 0s;
-moz-animation-iteration-count: 1;
-moz-animation-direction: alternate;
}
.openingIn {
/* Webkit */
-webkit-animation-name: open-card-in;
-webkit-animation-timing-function: ease;
-webkit-animation-duration: 3s;
-webkit-transition-delay: 0s;
-webkit-animation-iteration-count: 1;
-webkit-animation-direction: alternate;
/* Firefox */
-moz-animation-name: open-card-in;
-moz-animation-timing-function: ease;
-moz-animation-duration: 3s;
-moz-transition-delay: 0s;
-moz-animation-iteration-count: 1;
-moz-animation-direction: alternate;
}
.outOpen {
-webkit-transform: rotateY(180deg);
-webkit-transform-origin: 0 0;
-moz-transform: rotateY(180deg);
-moz-transform-origin: 0 0;
}
.inOpen {
-webkit-transform: rotateY(0deg);
-webkit-transform-origin: 0 0;
-moz-transform: rotateY(0deg);
-moz-transform-origin: 0 0;
}
/* Webkit */
#-webkit-keyframes open-card-out {
from {
-webkit-transform-origin: left 0%;
-webkit-transform: rotateY(0deg);
}
to {
-webkit-transform-origin: left 0%;
-webkit-transform: rotateY(-180deg);
}
}
#-webkit-keyframes open-card-in {
from {
-webkit-transform-origin: right 0%;
-webkit-transform: rotateY(180deg);
}
to {
-webkit-transform-origin: right 0%;
-webkit-transform: rotateY(0deg);
}
}
/* Firefox */
#-moz-keyframes open-card-out {
from {
-moz-transform-origin: left 0%;
-moz-transform: rotateY(0deg);
}
to {
-moz-transform-origin: left 0%;
-moz-transform: rotateY(-180deg);
}
}
#-moz-keyframes open-card-in {
from {
-moz-transform-origin: right 0%;
-moz-transform: rotateY(180deg);
}
to {
-moz-transform-origin: right 0%;
-moz-transform: rotateY(0deg);
}
}
/*****************************************
* Close
******************************************/
.closingOut {
/* Webkit */
-webkit-animation-name: close-card-in;
-webkit-animation-timing-function: ease;
-webkit-animation-duration: 3s;
-webkit-transition-delay: 0s;
-webkit-animation-iteration-count: 1;
-webkit-animation-direction: alternate;
/* Firefox */
-moz-animation-name: close-card-in;
-moz-animation-timing-function: ease;
-moz-animation-duration: 3s;
-moz-transition-delay: 0s;
-moz-animation-iteration-count: 1;
-moz-animation-direction: alternate;
}
.closingIn {
/* Webkit */
-webkit-animation-name: close-card-out;
-webkit-animation-timing-function: ease;
-webkit-animation-duration: 3s;
-webkit-transition-delay: 0s;
-webkit-animation-iteration-count: 1;
-webkit-animation-direction: alternate;
/* Firefox */
-moz-animation-name: close-card-out;
-moz-animation-timing-function: ease;
-moz-animation-duration: 3s;
-moz-transition-delay: 0s;
-moz-animation-iteration-count: 1;
-moz-animation-direction: alternate;
}
#-webkit-keyframes close-card-in {
from {
-webkit-transform: rotateY(-180deg);
-webkit-transform-origin: 0% 0%;
}
to {
-webkit-transform: rotateY(0deg);
-webkit-transform-origin: 0% 0%;
}
}
#-webkit-keyframes close-card-out {
from {
-webkit-transform-origin: right 0%;
-webkit-transform: rotateY(0deg);
}
to {
-webkit-transform-origin: right 0%;
-webkit-transform: rotateY(180deg);
}
}
#-moz-keyframes close-card-in {
from {
-moz-transform: rotateY(-180deg);
-moz-transform-origin: 0% 0%;
}
to {
-moz-transform: rotateY(0deg);
-moz-transform-origin: 0% 0%;
}
}
#-moz-keyframes close-card-out {
from {
-moz-transform-origin: right 0%;
-moz-transform: rotateY(0deg);
}
to {
-moz-transform-origin: right 0%;
-moz-transform: rotateY(180deg);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<div class="perspective" onclick="toggleCard();">
<div class="tile out out">
<div class="content">
<p>out</p>
</div>
</div>
<div class="tile in-left">
<div class="content">
<p>in-left</p>
</div>
</div>
<div class="tile in-right">
<div class="content">
<div style="display: table; height: 100%; width: 100%;">
<p>in-right</p>
</div>
</div>
</div>
</div>
As you can see, the in-left div opens in the same time as the out div if you're using Safari/Chrome, but on Firefox it will open at different times, messing up the whole animation.
How can I fix this?
An answer is not needed because the animation effects are the same in both browsers, stable builds tested.
Chrome:
19.0.1084.56 (Official Build 140965) m
Firefox:
Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0
How ironic this non-answer is an answer.
To be sure, flush out your browsers cache and test on another PC for verification.
I am agree with arttronics, I saw that you test all css3 available solutions but I think there are just 2 posible solution without using css3 at all
just wait until firefox improve its performance with css3 animation and transition, I personally think that this won't be for so long
to use an alternative to make that animation like canvas, I think that this is not going to be easy, but I think that this is a posible solution only if you really need that animation running