overwriting css animation with !important - css

So given this bug it's not reliable to overwrite an css animation using !important.
However, I'm in the following situation:
Open/ closing a list should be done by animating (using a css animation with keyframes) height on each of the elements in the list.
an order-by dropdown allows the elements in the list to be reordered. This is implemented by doing a (jquery) detach on all elements followed by an (jquery) append in the correct order. I want the reorder to happen instantly, without animations.
However, because of the detach/reattach the css animation kicks in again. resulting in a (albeit nicely animated) list growing from 0 height again to full-height no with elements in the correct order.
How to make bullet 2. work? I can't use css-classes to overwrite the height property using !important, because of the bug mentioned above. It seems there's no way to overwrite the properties set by the animation.
As an alternative I tried to set a css-class just before reorder (and remove just after reorder) that would do animation: none. Although that makes sure no animation happens during reorder, when I remove said class (and thus removing animation: none) AFTER the reorder happened, the initial css-class which has animation: <the fade in anim> for some reason kicks in the animation again, although it was already run once*
Any way out of this catch-22?
*) yeah I'm setting the animation as follows animation: 0.2s ease 0s normal forwards 1 fadeinTdSpan;, so it really should only run once.
However, probably due to adding the node to another parent, the cycle of animation restarts.

Related

How to loop a linear CSS3 animation

I am trying to animate a list of html elements with following CSS property:
animation: slide-right 10s linear infinite 0s;
Animation is perfect for me but, when list finish I would like to have a loop behaviour instead of a jerky transition that restart the animation because of infinite property of animation.
I tried to workaround it appending items via jQuery but it doesn't work. It's possible to do a loop animation with css3?
I got inspiration from this codepen: https://codepen.io/goomy/pen/vXKGGz
Thanks in advance
UPDATE: My code here
By "loop" I am going to assume you mean you want the element to re-appear from the bottom of the screen once it has vanished off the top of the screen.
One way to achieve this could be to set overflow-y: hidden on your body element, and then define the animation keyframes in terms of viewport height units, vh. If you translate an element to appear at y = 110vh then (assuming the document doesn't overflow) you know that it must appear off-screen since the very bottom of the body element is at 100vh. Similarly, you can transition to something like -10vh at the top, assuming the element is less than 10vh tall.
I modified your CodePen to illustrate this idea:
https://codepen.io/anon/pen/pwBxPL

Synchronizing transform transitions on multiple elements

I am using a slider plugin (http://roundsliderui.com/) and added additional elements to have a custom fill image. In Chrome, the transitions that happen when the slider is clicked are not synchronized even though the settings are the same. It only seems to happen in Chrome, and is worse on mobile. I am targeting Android with the Crosswalk webview, so it will affect all users, especially slower phones.
The plugin has one element that rotates the handle, and I add one child to clip the fill image (.rs-range-clip-custom, no transform) with a child that rotates back to vertical to hold the fill image as a background (.rs-range-custom). It is very noticeable for the actual images, since the fill will either leave a gap at the end or extend past the end of the track depending on the direction it is moving.
.rs-animation .rs-transition {/* plugin css */
transition: all .5s linear 0s;
}
.rs-animation .rs-range-custom {/* my css */
transition: transform 0.5s linear;
}
You can view a simplified version of the slider at http://codepen.io/MalikDrako/pen/XjbaWR
How can I ensure the two animations are synchronized?
Here i have customized the roundSlider in sample level to achieve your requirement.
In the below demo i have added an additional SVG element as range to apply the image for that. Please check the below demo, which demonstrate your requirement:
http://jsbin.com/debiyu/edit?html,output
For better understanding I have applied some other png images in the below demo, check that:
http://jsbin.com/henola/1/edit?html,output
From here you can customize further based on your requirement. I hope this helps you.. Please let me know your comments.

Rotation breaks in CSS animation when height/width is defined in keyframes

I've got an element which i'm trying to animate in. I want to do the animation in two steps, first scale and rotate a square in, and then widen the square. I start off by transform: scale(.1) rotateX(360deg); and animate to transform: none, which works well. But as soon as i (in any step) declare a height/width in the keyframes, the rotation stops working. It will still scale as it should, and the height/width properties are applied, but the rotation is skipped entirely.
Here is a Codepen to demonstrate the issue:
http://codepen.io/anon/pen/abDCK
As you see, there's no rotation going on in there, it just simply scales in. Now, scroll down in the CSS and comment out the height/width properties, and you'll see that the rotation now suddenly works.
I've tried different combinations of having/not having height/width declared in the normal selector (not in the keyframe), i've also tried putting the height/width declarations in different steps in the keyframes. No success.
I get the same result in both Firefox in Chrome. Is this the intended behaviour? If so, why? Are there any workarounds?
Something to do with the transforms in the keyframes not being balanced?. You need to add translateX(0deg) to either the 40% keyframe, of 100% keyframe, depending on where you want it.
http://codepen.io/anon/pen/lJKkD
I'd sure love it if somebody could explain the reason - but this is the "solution"

There's a way to prevent the return to the original CSS style after an animation?

What I need to do is something like an auto-start transition. But the transitions can't start automatically, so I thought to utilize an animation that not return to the original CSS style of an element after the end of the animation.
animation-fill-mode: forwards is what you're looking for. This makes the element keep the values from the last keyframe of the animation.
More documentation here: https://developer.mozilla.org/en-US/docs/Web/CSS/animation-fill-mode

Adding two CSS3 animations?

I am trying to apply a Minecraft-like style to a div element. The end result should look something like the "if not ok then return end" message:
Quick sidenote: For those of you who haven't played the game, a random line from a specific file is read and it's contents are displayed as the message of the day. It throbs in and out and grabs your attention.
The text shadow, font, and throbbing animation has already been done. However, when I try to apply the second animation, it overrides the throbbing animation (meaning it does not throb, but is rotated)
My CSS is as follows:
#random-message {
/* font/text stuff */
animation:minecraft, minecraft-rotate 0.5s infinite;
-webkit-animation:minecraft 0.5s infinite; /* Safari and Chrome */
}
The animation minecraft applies a transform: scale effect, and minecraft-rotate applies a transform: rotate effect.
What would be the best way to implement a rotation effect without overriding my throbbing effect?
You don't want to have a rotation animation...you want to rotate the div. Simply add transform: rotate(340deg); line to the css block.
Any given element can have only one transform at any given time. Any attempt to set at the same time 2 transforms will result in one of them being overriden.
You can:
1) set two divs, one inside the other, and apply a different transform to the parent and to the child.
2) build the composite transform. In the case of an animation, that means creating composite transforms for each frame.

Resources