Issue
I want to start a animtion on click of a div and after the animtion is done it just keeps it position. I fixed the anitmtion that i works on reloading the page but didnt fix it for onclick do you guys have an idea??
.tsx file:
import styles from "./WaterTracker.module.css";
export default function WaterTracker() {
return (
<div className={styles.mainContainer}>
<div className={styles.wrapper}>
<div className={styles.mainContent}></div>
</div>
</div>
);
}
.css file :
:root {
--background: #f8f8f8;
--dark: #303032;
}
.mainContainer {
box-sizing: border-box;
margin: 0 0;
padding: 0 0;
}
.wrapper {
background: var(--background);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.mainContent {
position: relative;
background: var(--dark);
border: 0.25em solid var(--dark);
height:8rem;
width: 8rem;
outline: 0.25;
overflow: hidden;
}
.mainContent::before {
content: "Drink je water";
font-size: 2rem;
color: white;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.mainContent::after {
content: "";
position: absolute;
background: var(--background);
height: 200%;
width: 200%;
bottom: -50%;
left: -50%;
border-radius: 45%;
animation: spin 6s ease-in-out forwards;
}
@keyframes spin {
0% {
transform: translateY(0) rotate(0deg);
}
100% {
transform: translateY(-100%) rotate(500deg);
}
}
I hope that when this works i also can change the tranlateY from -100% to any number with a button so the animtion will first go to -50% and when i click on the button to -100% if you guys have a fix for this as whel it would be nice
Solution
You can use Ionic’s Animation. Check out the docs for examples. https://ionicframework.com/docs/utilities/animations
Answered By – StackoverBlows
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0