Last active
October 29, 2021 18:22
-
-
Save kerenren/ab47aa8708bce156d35d67b38e3c5f47 to your computer and use it in GitHub Desktop.
scss notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// how to create a clockwise rotate animation with SwitchTransition and CSSTransition approach | |
// jsx | |
<div className="rotating-icon"> | |
<SwitchTransition> | |
<CSSTransition | |
key={state ? 'faChevronDown' : 'faChevronUp'} | |
addEndListener={(node, done) => node.addEventListener('transitionend', done, false)} | |
classNames="rotate" | |
timeout={125} | |
> | |
<FontAwesomeIcon icon={state ? faChevronDown : faChevronUp} onClick={handleClick} /> | |
</CSSTransition> | |
</SwitchTransition> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// how to create a clockwise rotate animation with SwitchTransition and CSSTransition approach | |
// scss: | |
.rotate-enter { | |
transform: rotate(-90deg); | |
} | |
.rotate-exit { | |
transform: rotate(0); | |
} | |
.rotate-enter-active { | |
transform: rotate(0); | |
transition: transform 300ms ease-out; | |
} | |
.rotate-exit-active { | |
transform: rotate(90deg); | |
transition: transform 300ms ease-in; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// staggered dropdown menu list item animation with nesting @for flow control selector | |
@keyframes staggered-drop-down { | |
0% { | |
opacity: 0; | |
transform: rotateX(-90deg); | |
} | |
50% { | |
transform: rotateX(-20deg); | |
} | |
100% { | |
opacity: 1; | |
transform: rotateX(0deg); | |
} | |
} | |
#id .class li { | |
animation: staggered-drop-down 300ms ease-in-out; | |
animation-fill-mode: both; | |
// for the first 10 selected list items | |
@for $i from 1 through 10 { | |
&:nth-child(#{$i}) { | |
animation-delay: 100ms * $i + 35ms; | |
} | |
} | |
} | |
Reference: | |
Daniel, B.(2019, June 27). Different Approaches for Creating a Staggered Animation[Blog post]. Retrieved from https://css-tricks.com/different-approaches-for-creating-a-staggered-animation/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment