I'm trying to use loader inside button along with text. I've modified example from vuetify documentation:
<span slot="loader">
<v-icon light class="custom-loader">cached</v-icon>
Loading...
</span>
codepen
On click event button text changes and loader appears. However button's content is not inline.
Please advise how to make button content composed inline and independent of text width?
DEMO: https://codepen.io/anon/pen/ejgEoO
I've added styles for the classes used by vuetify: .v-btn__loading and .v-btn--loader .v-btn__content: So your CSS becomes:
.v-btn__loading {
position: relative;
}
.v-btn--loader .v-btn__content {
display: none;
}
.custom-loader {
animation: loader 1s infinite;
}
#-moz-keyframes loader {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
#-webkit-keyframes loader {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
#-o-keyframes loader {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
#keyframes loader {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
Related
I'm doing some CSS animations inside a modal dialog. Here's the pertinent SCSS:
#keyframes grow {
from {
transform: scale(1);
}
to {
transform: scale(1.1);
}
}
#keyframes shrink {
from {
transform: scale(1.1);
}
to {
transform: scale(1);
}
}
$duration: 0.5s;
$animationFillMode: both;
&:not(.active):hover, &.active {
img {
animation: grow $duration $animationFillMode;
}
}
&:not(.active) {
img {
animation: shrink $duration $animationFillMode;
}
}
This works well but the problem is, when I open the modal, the animations kick in immediately. For example, because when the modal is first open I'm not hovering on one of the elements, the element instantly shrinks from big to small. I want the element to start in the small state when the modal is open.
Is is possible? TIA
Yes it is, use reverse tag.
Example: animation-direction: reverse;
So I have this arrow that rotates when the .collapse class is applied:
then
The css is:
.my-arrow {
background: url('arrow.svg');
transition: transform ease 0.2s;
transform: rotate(0deg);
&.collapse {
transform: rotate(90deg);
}
}
I also wanted to add a hover effect, for better user feedback.
But if I add:
.my-arrow {
&:hover {
rotate(90deg);
}
&.collapse {
&:hover {
rotate(0deg);
}
}
}
It works on hover, but when I click (= add the .collapse class), it rotates back to 0deg, because the mouse is still hovering the div, which is even more confusing.
Is there any way to tackle this issue? I guess I could do this is JS with an extra class that would toggle onmouseleave, but this is way too complicated for my use case.
I tried with CSS animations:
#keyframes rotate {
0% {
transform: rotate(0);
}
100% {
transform: rotate(90deg);
}
}
#keyframes rotate-back {
0% {
transform: rotate(90deg);
}
100% {
transform: rotate(0);
}
}
.my-arrow {
&:hover {
animation: rotate .2s ease 1;
}
.collapse {
&:hover {
animation: rotate-back .2s ease 1;
}
}
without success, and I'm very n00b in CSS animations. Maybe with a delay?
Cheers
.hover-rotate{
transition: transform .3s; /* Apply the transition property. Enables the animation */
}
.hover-rotate:hover{
transform: rotate(90deg); /* Rotate if mouse is hovered */
}
.hover-rotate.collapse{
transform: rotate(90deg); /* Rotate if collapse class is present */
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet"/>
<i class="hover-rotate fa fa-chevron-right"></i>
You can use the CSS transition property to make this animation. The above code animates if either mouse hovers over the icon or the class .collapse is applied.
I read documents, and I used keyframes`` for declare css animation.
But I got error message like this:
Please wrap your string in the css`` helper which ensures the styles are injected correctly.
So, I wrapped animation with css`` instead keyframes``, but animation didn't work.
const rippleAnimation = css`
0% {
transform: translate(-50%, -50%) scale(1);
}
100% {
transform: translate(-50%, -50%) scale(var(--material-scale));
opacity: 0;
}
`;
This didn't work well.
I don't know I wrote perfectly...
ordinary code(error about keyframes) :
const rippleAnimation = keyframes`
0% {
transform: translate(-50%, -50%) scale(1);
}
100% {
transform: translate(-50%, -50%) scale(var(--material-scale));
opacity: 0;
}
`;
You can do it like this. Create keyframes in CSS. And add the keyframes with js. You can also add this keyframe after clicking in js.
const hello = document.querySelector(".hello")
hello.style.animation = "5s colorChange linear infinite"
.hello {
color: #000000;
}
#keyframes colorChange {
0% {
color: black;
}
50% {
color: red;
}
100% {
color: black;
}
}
<h1 class="hello">Hello World</h1>
I am new to React. I have a small app with a login button. When I click the login button and a error from the backend is triggered, a toast error message is rendered. I want to show a animation fade-in and fade out from bottom to top. Only the fade in animation for the toast message is currently working. But how can i trigger a fade out animation?
the errorMessage comes from the redux mapStateToProps function. The clearAuthErrorAction is an action, it will delete the error message from the redux state.
<AuthenticationAlert errorMessage={errorMessage}>
{setTimeout(() => clearAuthErrorAction(), 3000)}
</AuthenticationAlert>
.toast__container {
...
animation: slideInTop 0.5s linear;
}
#keyframes slideInTop {
0% {
transform: translateY(-1.5rem);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
#keyframes slideInBottom {
0% {
transform: translateY(1.5rem);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
The solution was simple. I adjusted the animation in CSS a little bit.
#keyframes slideInTop {
0% {
transform: translateY(-3rem);
opacity: 0;
}
50% {
transform: translateY(0);
opacity: 1;
}
100% {
transform: translateY(-20rem);
opacity: 0;
}
}
I have started building a website using ReactJS, I want to animate div elements into view when the view in scrolled to.
I have used CSS keyframes to add animations like so;
.animateMe {
animation: IntroWelcomeImageAnimation 3s 0.2s forwards cubic-bezier(0.2, 0.8, 0.2, 1);
}
#keyframes IntroLeftAnimation {
0% {
opacity: 0;
transform: translateX(-200px)
}
100% {
opacity: 1;
transform: translateY(0px)
}
}
#keyframes IntroRightAnimation {
0% {
opacity: 0;
transform: translateX(200px)
}
100% {
opacity: 1;
transform: translateY(0px)
}
}
#keyframes IntroWelcomeImageAnimation {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
JS File
import React from 'react'
import '../../layout/intro.css';
const IntroPage = () => {
return (
<section className="Intro-Page">
<div className="animateme">
</div>
</section>
)
}
export default IntroPage
However the problem is that the animations only occur when the page is loaded as that is when the elements are too. How can I have it that they transition into view on scroll without using JQuery ?
Look at this library https://www.react-reveal.com/
there are many animations that can be triggered on scroll