action
action = sur la plupart des slides, il se passe quelque chose quand on clique dessus (surtout la slide 18 :-)
Martin Gorner
Dataconnexions II, Paris le 20 juin 2012
left: 0px; |
onclick |
left: 500px; |
left: 0px; -webkit-transition: 1s; |
onclick |
left: 500px; -webkit-transition: 1s; |
On peut combiner les propriétés CSS.
left: 0px; -webkit-transform: rotate(0deg); -webkit-transition: 1s; |
onclick |
left: 500px; -webkit-transform: rotate(360deg); -webkit-transition: 1s; |
-webkit-transition-timing-function:
-webkit-transition: 1s cubic-bezier(0, 0.9, 0.1, 1);
-webkit-transition: -webkit-transition-delay: -webkit-transition-duration: -webkit-transition-property: -webkit-transition-timing-function:
.move { -webkit-animation: anim1 5s linear infinite; } @-webkit-keyframes anim1 { from {-webkit-transform: rotate(0deg); } to {-webkit-transform: rotate(360deg); } }
.move {-webkit-animation: anim2 ease-in-out 3s infinite alternate; } @-webkit-keyframes anim2 { from {left: 0px; -webkit-transform: scale(1.0) rotate(0deg) } 50% {left: 250px; -webkit-transform: scale(0.8) rotate(10deg) } to {left: 500px; -webkit-transform: scale(1.2) rotate(-20deg) } }
-webkit-animation: -webkit-animation-name: -webkit-animation-delay: -webkit-animation-duration: -webkit-animation-direction: -webkit-animation-fill-mode: -webkit-animation-timing-function: -webkit-animation-iteration-count:
-webkit-transform: |
-webkit-transform: |
-webkit-transform: |
liste complète des transformations 2D:
rotate, scale, skew, translate, matrix
On peut spécifier l'origine de la transformation.
-webkit-transform-origin: 0% 100%; -webkit-transform: rotate(360deg);
-webkit-opacity: 0.4 |
-webkit-box-shadow: |
-webkit-box-reflect: |
opacity | box-shadox text-shadow |
box-reflection |
rotateX, rotateY, rotateZ, rotate3d, matrix3d
-webkit-transform: rotateY(360deg);
translateX, translateY, translateZ, translate3d
-webkit-transform: translateZ(150px) /* first picture */ -webkit-transform: translateZ(-150px) /* second picture */
-webkit-perspective: 1000px;
-webkit-perspective: f
-webkit-transform-style: flat; /* default value */
-webkit-transform-style: preserve-3d;
.SCENE { -webkit-perspective: 1000px; width: 600px; height: 340px; } .OBJECT { -webkit-transform-style: preserve-3d; -webkit-transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); position: absolute; width: 100%; height: 100%; } .FACE { position: absolute; left: 165px; top: 15px; } .FACE.im1 { -webkit-transform: translateZ(150px); } .FACE.im2 { -webkit-transform: translateZ(-150px); } .FACE.im3 { -webkit-transform: translateX(150px) rotateY(90deg);} .FACE.im4 { -webkit-transform: translateX(-150px) rotateY(-90deg);} .FACE.im5 { -webkit-transform: translateY(150px) rotateX(90deg);} .FACE.im6 { -webkit-transform: translateY(-150px) rotateX(-90deg);}
<line x1 y1 x2 y2>
<rect x y width height>
<circle cx cy r>
<path d>
<image x y width height xlink:href>
<svg> <rect x="5" y="5" width="140" height="140" stroke="#000000" stroke-width="4" fill="#AAAAFF" opacity="1"/> </svg>
L - ligne |
C - bézier cubique |
Q - bézier quadratique |
A - arc d'ellipse |
M - Marqueur (nlle. pos. stylo) |
z - pour fermer la courbe |
<svg> <path d="M 30,240 Q 170,40 260,230" stroke="#F00" /> <path d="M 30,240 C 70,90 210,150 260,230" stroke="#F00" /> </svg>
transform = |
transform = |
transform = |
liste complète des transformations 2D:
translate, rotate, scale, skewX, skewY, matrix
<rect ... transform="translate(10,10) rotate(25) scale(2)">
<circle cx="200" cy="205" r="80" > <animate dur="3s" attributeName="r" values="80; 150; 80" repeatCount="indefinite" /> </circle>
<path fill="#fff"> <animate attributeName="d" dur="2s" repeatCount="indefinite" values="m 0,0 c 1,15 -13,45 -45,45 -32,0 -44,-28 -44,-44 z; m 0,0 c -4,15 -66,106 -98,106 -32,0 3,-89 9,-105 z" /> </path>
<g> ... <!-- formes SVG groupées ici --> <animateTransform dur="3s" repeatCount="indefinite" additive="sum" attributeName="transform" type="translate" values="0,0; 200,-130" /> <animateTransform dur="3s" repeatCount="indefinite" additive="sum" attributeName="transform" type="rotate" values="0; 20" /> </g>
<g>
... <!-- formes SVG groupées ici -->
<animateMotion dur="1s" repeatCount="indefinite"
path="m 0,0 a 15,11 0 1 1 -30,0 15,11 0 1 1 30,0 z" />
</g>
<animateTransform calcMode="spline" dur="3s" attributeName="transform" type="rotate" repeatCount="indefinite" keySplines="0.35 0 0.65 1; 0.35 0 0.65 1" values="20,310,400; -20,310,400; 20,310,400" />
<animate begin="..." end="..." fill="freeze" ... />
Un temps:
begin="1s"
Un événement souris:
begin="buttonID.click"
Un événement d'animation:
begin="animID.end"
Une combinaison de tout ça:
begin="animID.end + 1s; 10s"
unpauseAnimations()
pauseAnimations()
setCurrentTime(0)
<g onclick="document.getElementById('svg_id').pauseAnimations()">...</g>
CSS3 | déclaratif | objets HTML uniquement, aucun contrôle de trajectoire |
SVG + SMIL | déclaratif | courbes, trajectoires courbes mais préprogrammées |
Canvas + Javascript | programmatique | boucle d'animation avec modèle et interactions libres, 2D uniquement |
WebGL | programmatique | full 3D |
chrome
Contact:
Martin Gorner, Relations Développeurs, Google
Google+: gplus.to/martin.gorner
Cette présentation est en ligne:
http://animateyourhtml5.appspot.com
Plus d'infos:
http://html5rocks.com