Johan Bijlsma - ShareValue
Transitions enable you to define the transition between two states of an element. Different states may be defined using pseudo-classes like
:hover
or:active
or dynamically set using JavaScript. (bron: MDN )
The animation shorthand property is a comma-separated list of animation definitions. Each item in the list gives one item of the value for all of the subproperties of the shorthand, which are known as the animation properties. (bron: W3C )
de Syntax is vrij simpel:
/* property name | duration | timing function | delay */
transition: margin-right 4s ease-in-out 1s;
Maar je kunt ook verschillende properties stylen:
/* property name | duration | timing function | delay */
transition: margin-right 4s ease-in-out 1s,
background-color 2s linear 50ms;
Hiermee kun je met 1 CSS declaration meerdere transitions mee geven.
Daarnaast bestaan ook de attributes all
en none
.
de animation syntax is iets complexer:
/* @keyframes duration | timing-function | delay |
iteration-count | direction | fill-mode | play-state | name */
animation: 3s ease-in 1s 2 reverse both paused slidein;
Bovenstaande code wordt toegegevoegd aan het element dat je wil animeren. Maar eerst moet de animatie nog worden gedefinieerd
Een @keyframes animatie
@keyframes bgFade {
0% {
background-color: rgba(255, 255, 255, 0.2);
}
100% {
background-color: rgba(197, 29, 29, 0.45);
}
}
Een @keyframes
animatie moet een minimaal een naam hebben. Percentages zijn niet verplicht (from
en to
zijn ook toegestaan).
De syntax is iets complexer dan CSS :
const animation = element.animate(keyframes, options);
Greensock is een JavaScript Animation Framework
Greensock biedt een hoop extra mogelijkheden.
gsap.to
gsap.from
gsap.timelime
GSAP demo
GSAP demo
Bring your components to life with simple spring animation primitives...
Bring your components to life with simple spring animation primitives...