SlideShare a Scribd company logo
Animation, Transition and
   Transform in CSS3
Contents of Transforms
• CSS3 Transforms
  – Transform rendering model
  – 3D Transform Rendering model
  – Properties, Functions
Transforms?
• With transform, we can
  – Move
  – Scale
  – Turn
  – Spin
  – Stretch
Transform rendering model
• Elements establish their local coordinate
  system within the coordinate system of their
  parent.
<div style=“transform: translate(80px, 80px)">
  <div style=“transform: scale(1.5, 1.5)">
     <div style=“transform: rotate(45deg)"></div>
  </div>
</div>
<div style=“transform: translate(80px, 80px)">
  <div style=“transform: scale(1.5, 1.5)">
     <div style=“transform: rotate(45deg)"></div>
  </div>
</div>
.t {
   height: 100px; width: 100px;
   transform: translate(80px, 80px) rotate(45deg);
   background-color: yellow;
   opacity: 0.5
}

<div class='t'>
  <div class='t'>
    <div class='t'></div>
  </div>
</div>
.t {
   height: 100px; width: 100px;
   transform: translate(80px, 80px) rotate(45deg);
   background-color: yellow;
   opacity: 0.5
}

<div class='t'>
  <div class='t'>
    <div class='t'></div>
  </div>
</div>
• http://www.w3.org/TR/CSS2/visudet.html
• CSS2 Visual formatting model
   – Effects are applied after elements have been sized and
     positioned according to the Visual formatting model
     from [CSS21]
• Some values of these properties result in the
  creation of a containing block, and/or the
  creation of a stacking context(z-index).
   – Box positions and sizes are calculated with respect to
     the edges of a rectangular box called a containing
     block
<div style='width: 200px; height: 200px;
overflow: auto'>
<div class='t'>
  <div class='t'>
    <div class='t'></div>
  </div>
</div>
</div>
• Fixed backgrounds are affected by any transform
  specified for the root element, and not by any
  other transforms.
• If the root element's background were repeating
  dots, and a transformation of ‘scale(0.5)’ were
  specified on the root element, the dots would
  shrink to half their size, but there will be twice as
  many, so they still cover the whole viewport. ( Did
  not operate(implemented)? Is wrong example
  code?)
• http://jsfiddle.net/freestrings/WQs9P/
3D Transform Rendering
The scaling is proportional to d/(d − Z) where d, the
value of ‘perspective’, is the distance from the drawing
plane to the the assumed position of the viewer's eye.
div {
   height: 150px;
   width: 150px;
}
.container {
border: 1px solid black;
}
.transformed {
   background-color: blue;
   -webkit-transform: rotateY(50deg);
}

<div class="container">
  <div class="transformed"></div>
</div>
div {
   height: 150px;
   width: 150px;
}
.container {
border: 1px solid black;
}
.transformed {
   background-color: blue;
   -webkit-transform: rotateY(50deg);
}

<div class="container">
  <div class="transformed"></div>
</div>
div {
   height: 150px;
   width: 150px;
}
.container {
   -webkit-perspective: 500px;
   border: 1px solid black;
}
.transformed {
   background-color: blue;
   -webkit-transform: rotateY(50deg);
}

<div class="container">
  <div class="transformed"></div>
</div>
div {
   height: 150px;
   width: 150px;
}
.container {
   -webkit-perspective: 500px;
   border: 1px solid black;
}
.transformed {
   background-color: blue;
   -webkit-transform: rotateY(50deg);
}

<div class="container">
  <div class="transformed"></div>
</div>
.container {
   -webkit-perspective: 500px;
   border: 1px solid black;
}
.transformed {
   -webkit-transform: rotateY(50deg);
   background-color: blue;
}
.child {
   -webkit-transform-origin: top left;
   -webkit-transform: rotateX(40deg);
   background-color: lime;
}

<div class="container">
  <div class="transformed">
    <div class="child"></div>
  </div>
</div>
• The lime element is being rendered into the
  plane of its parent because it is not a member
  of a 3D rendering context; the parent is
  "flattening"
.container {
   -webkit-perspective: 500px;
   border: 1px solid black;
}
.transformed {
   -webkit-transform-style: preserve-3d;
   -webkit-transform: rotateY(50deg);
   background-color: blue;
}
.child {
   -webkit-transform-origin: top left;
   -webkit-transform: rotateX(40deg);
   background-color: lime;
}

<div class="container">
  <div class="transformed">
     <div class="child"></div>
  </div>
</div>
.container {
   -webkit-perspective: 500px;
   border: 1px solid black;
}
.transformed {
   -webkit-transform-style: preserve-3d;
   -webkit-transform: rotateY(50deg);
   background-color: blue;
}
.child {
   -webkit-transform-origin: top left;
   -webkit-transform: rotateX(40deg);
   background-color: lime;
}

<div class="container">
  <div class="transformed">
     <div class="child"></div>
  </div>
</div>
• The blue element now establishes a 3D
  rendering context, of which the lime element
  is a member. Now both blue and lime
  elements share a common three-dimensional
  space, so the lime element renders as tilting
  out from its parent, influenced by the
  perspective on the container.
.container {
  background-color: rgba(0, 0, 0, 0.3);
  transform-style: preserve-3d;
  perspective: 500px;
                                             In safari
}
.container > div {
  position: absolute; left: 0;
}
.container > :first-child {
  transform: rotateY(45deg);
  background-color: orange;
  top: 10px;
  height: 135px;
}
                                                         In chrome
.container > :last-child {
  transform: translateZ(40px);
  background-color: rgba(0, 0, 255, 0.75);
  top: 50px;
  height: 100px;
}
Properties, Functions
• ‘transform’ property
  – This property contains a list of transform
    functions.
• ‘transform-origin’ property
  – This property must be used together with the
    ‘transform’ property.
  – http://www.w3schools.com/cssref/css3_pr_transf
    orm-origin.asp
• ‘transform-style’ property
    – flat|preserve-3d
• ‘perspective’ property
    – http://www.w3schools.com/cssref/trycss3_perspective_inuse.htm
• ‘perspective-origin’ property
    – The resolved value of ‘perspective-origin’ is the used value (i.e.,
      percentages are resolved to absolute lengths).
    – https://developer.mozilla.org/en/CSS/perspective-origin (firefox)
• ‘backface-visibility’ property
    – Determines whether or not the "back" side of a transformed element
      is visible when facing the viewer.
    – visible | hidden
• transform function
  – matrix, matrix3d
  – translate|X|Y|Z|3d
  – scale|X|Y|Z|3d
  – rotate|X|Y|Z|3d
  – skew|X|Y
  – perspective
And many other things in transforms
•   SVG transform
•   Matrix Decomposition for Animation
•   Unmatrix
•   Recomposing the matrix
•   Mathematical Description of Transform
    Functions
Transition Contents
• CSS3 Transitions
  – Transitions
  – Properties and Funtions
  – Events
Transitions
• Animate smoothly from the old state to the
  new state over time.
• Must specify two things
  – Specify the CSS property you want to add an effect
    to
  – Specify the duration of the effect
Properties and Functions
• Properties
  – transition ( shorthand property)
  – transition-property (Specifies the name of the CSS
    property to which the transition is applied)
  – transition-duration (Defines the length of time that a
    transition takes. Default 0)
  – transition-timing-function (Describes how the speed
    during a transition will be calculated. Default "ease”)
  – transition-delay (Defines when the transition will
    start. Default 0)
• ‘transition-timing-function’ details
   – stepping function
        • A stepping function is defined by a number that divides the domain of
          operation into equally sized intervals
   – cubic Bézier curve
        • http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_
          curves
• Functions
   –   ease = cubic-bezier(0.25, 0.1, 0.25, 1.0).
   –   linear = cubic-bezier(0.0, 0.0, 1.0, 1.0).
   –   ease-in = cubic-bezier(0.42, 0, 1.0, 1.0).
   –   ease-out = cubic-bezier(0, 0, 0.58, 1.0).
   –   ease-in-out = cubic-bezier(0.42, 0, 0.58, 1.0)
   –   cubic-bezier(n, n, n, n)
• Functions
   –   linear = the same speed from start to end
   –   ease = a slow start, then fast, then end slowly
   –   ease-in = a slow start.
   –   ease-out = a slow end.
   –   ease-in-out = a slow start and end
Transition Events
• transitionend
  – Event occurs at the completion of the transition
Animations Contents
• CSS3 Animations
  – Animations
  – Keyframes
  – Properties
  – Events
Animations
• Animations are similar to transitions in that
  they change the presentational value of CSS
  properties over time.
• The principal difference is that while
  transitions trigger implicitly when property
  values change, animations are explicitly
  executed when the animation properties are
  applied. ( Because animation require a name
  of keyframe.)
keyframes
• Keyframes are used to specify the values for
  the animating properties at various points
  during the animation.
• The keyframes specify the behavior of one
  cycle of the animation.
• Use a ‘CSS at-rule’, @keyframes
• Timing functions for keyframes

@keyframes bounce {
   from {
     top: 100px; animation-timing-function: ease-out;
   }
   50% {
     top: 100px; animation-timing-function: ease-in;
   }
   to {
     top: 100px;
   }
 }
Properties
• animation : A shorthand property, except the animation-play-state
  property
• animation-name : name of the @keyframes animation
• animation-duration
• animation-timing-function : See transition functions
• animation-delay
• animation-iteration-count : The number of times an animation is
  played.
• animation-direction : Specifies whether or not the animation should
  play in reverse on alternate cycles.
• animation-play-state : Whether the animation is running or paused.

• http://www.w3schools.com/css3/css3_animations.asp
Events
• animationstart
• animationend
• animationiteration
Let’s make!
Spinner
• Draw a bar.
.loading.bar div{
   width: 10px;
   height: 30px;
   background: black;
   position: absolute;
   top: 35px;
   left: 45px;
   opacity:0.05;
   -webkit-animation: fadeit 1.1s linear infinite;
}
• positioning.
.loading.bar div:nth-child(1){
   -webkit-transform: rotate(0deg) translate(0, -30px);
   -webkit-animation-delay:0.39s;
}
…
.loading.bar div:nth-child(8){
   -webkit-transform: rotate(315deg) translate(0, -30px);
   -webkit-animation-delay:1.3s;
}
• iteration.

@-webkit-keyframes fadeit{
  0%{
    opacity:1;
  }
  100%{
    opacity:0;
  }
}
• http://jsfiddle.net/freestrings/mLu22/
CSS3 TTA (Transform Transition Animation)
• When the computed value of an animatable
  property changes, implementations must
  decide what transitions to start
• ul
   – perspective: 600px;
   – perspective-origin: 0% 50%;
• li
   – transition: all 600ms ease, opacity 200ms ease;
   – transform-origin: 0% 0%;
• .future or .past
   – transform: rotateY(90deg);
   – opacity : 0;
• Real sample
  – http://lab.hakim.se/scroll-effects/
• Conceptual implementation
  – http://jsfiddle.net/freestrings/hdbUv/
Ad

More Related Content

Similar to CSS3 TTA (Transform Transition Animation) (20)

Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive Graphics
Blazing Cloud
 
Iagc2
Iagc2Iagc2
Iagc2
Lee Lundrigan
 
Css3
Css3Css3
Css3
Knoldus Inc.
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using css
Dhairya Joshi
 
SVGD3Angular2React
SVGD3Angular2ReactSVGD3Angular2React
SVGD3Angular2React
Oswald Campesato
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
Robyn Overstreet
 
Mastering CSS Animations
Mastering CSS AnimationsMastering CSS Animations
Mastering CSS Animations
Goodbytes
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
Thomas Fuchs
 
Workshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsWorkshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effects
Visual Engineering
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 features
Gill Cleeren
 
Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017 Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017
Anna Migas
 
SVG, CSS3, and D3 for Beginners
SVG, CSS3, and D3 for BeginnersSVG, CSS3, and D3 for Beginners
SVG, CSS3, and D3 for Beginners
Oswald Campesato
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
Robert Nyman
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
Rob LaPlaca
 
Make your animations perform well
Make your animations perform wellMake your animations perform well
Make your animations perform well
Anna Migas
 
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte eventHTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
Robert Nyman
 
Visual State Manager
Visual State ManagerVisual State Manager
Visual State Manager
Jeremy Likness
 
CSS3: Ready for Primetime?
CSS3: Ready for Primetime?CSS3: Ready for Primetime?
CSS3: Ready for Primetime?
Jeff Bridgforth
 
CSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - ImrokraftCSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - Imrokraft
imrokraft
 
PreDevCampSF - CSS3 Tricks
PreDevCampSF - CSS3 TricksPreDevCampSF - CSS3 Tricks
PreDevCampSF - CSS3 Tricks
incidentist
 
Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive Graphics
Blazing Cloud
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using css
Dhairya Joshi
 
Mastering CSS Animations
Mastering CSS AnimationsMastering CSS Animations
Mastering CSS Animations
Goodbytes
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
Thomas Fuchs
 
Workshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effectsWorkshop 18: CSS Animations & cool effects
Workshop 18: CSS Animations & cool effects
Visual Engineering
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 features
Gill Cleeren
 
Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017 Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017
Anna Migas
 
SVG, CSS3, and D3 for Beginners
SVG, CSS3, and D3 for BeginnersSVG, CSS3, and D3 for Beginners
SVG, CSS3, and D3 for Beginners
Oswald Campesato
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
Robert Nyman
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
Rob LaPlaca
 
Make your animations perform well
Make your animations perform wellMake your animations perform well
Make your animations perform well
Anna Migas
 
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte eventHTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
Robert Nyman
 
CSS3: Ready for Primetime?
CSS3: Ready for Primetime?CSS3: Ready for Primetime?
CSS3: Ready for Primetime?
Jeff Bridgforth
 
CSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - ImrokraftCSS3 Animation for beginners - Imrokraft
CSS3 Animation for beginners - Imrokraft
imrokraft
 
PreDevCampSF - CSS3 Tricks
PreDevCampSF - CSS3 TricksPreDevCampSF - CSS3 Tricks
PreDevCampSF - CSS3 Tricks
incidentist
 

CSS3 TTA (Transform Transition Animation)

  • 1. Animation, Transition and Transform in CSS3
  • 2. Contents of Transforms • CSS3 Transforms – Transform rendering model – 3D Transform Rendering model – Properties, Functions
  • 3. Transforms? • With transform, we can – Move – Scale – Turn – Spin – Stretch
  • 4. Transform rendering model • Elements establish their local coordinate system within the coordinate system of their parent.
  • 5. <div style=“transform: translate(80px, 80px)"> <div style=“transform: scale(1.5, 1.5)"> <div style=“transform: rotate(45deg)"></div> </div> </div>
  • 6. <div style=“transform: translate(80px, 80px)"> <div style=“transform: scale(1.5, 1.5)"> <div style=“transform: rotate(45deg)"></div> </div> </div>
  • 7. .t { height: 100px; width: 100px; transform: translate(80px, 80px) rotate(45deg); background-color: yellow; opacity: 0.5 } <div class='t'> <div class='t'> <div class='t'></div> </div> </div>
  • 8. .t { height: 100px; width: 100px; transform: translate(80px, 80px) rotate(45deg); background-color: yellow; opacity: 0.5 } <div class='t'> <div class='t'> <div class='t'></div> </div> </div>
  • 9. • http://www.w3.org/TR/CSS2/visudet.html • CSS2 Visual formatting model – Effects are applied after elements have been sized and positioned according to the Visual formatting model from [CSS21] • Some values of these properties result in the creation of a containing block, and/or the creation of a stacking context(z-index). – Box positions and sizes are calculated with respect to the edges of a rectangular box called a containing block
  • 10. <div style='width: 200px; height: 200px; overflow: auto'> <div class='t'> <div class='t'> <div class='t'></div> </div> </div> </div>
  • 11. • Fixed backgrounds are affected by any transform specified for the root element, and not by any other transforms. • If the root element's background were repeating dots, and a transformation of ‘scale(0.5)’ were specified on the root element, the dots would shrink to half their size, but there will be twice as many, so they still cover the whole viewport. ( Did not operate(implemented)? Is wrong example code?) • http://jsfiddle.net/freestrings/WQs9P/
  • 12. 3D Transform Rendering The scaling is proportional to d/(d − Z) where d, the value of ‘perspective’, is the distance from the drawing plane to the the assumed position of the viewer's eye.
  • 13. div { height: 150px; width: 150px; } .container { border: 1px solid black; } .transformed { background-color: blue; -webkit-transform: rotateY(50deg); } <div class="container"> <div class="transformed"></div> </div>
  • 14. div { height: 150px; width: 150px; } .container { border: 1px solid black; } .transformed { background-color: blue; -webkit-transform: rotateY(50deg); } <div class="container"> <div class="transformed"></div> </div>
  • 15. div { height: 150px; width: 150px; } .container { -webkit-perspective: 500px; border: 1px solid black; } .transformed { background-color: blue; -webkit-transform: rotateY(50deg); } <div class="container"> <div class="transformed"></div> </div>
  • 16. div { height: 150px; width: 150px; } .container { -webkit-perspective: 500px; border: 1px solid black; } .transformed { background-color: blue; -webkit-transform: rotateY(50deg); } <div class="container"> <div class="transformed"></div> </div>
  • 17. .container { -webkit-perspective: 500px; border: 1px solid black; } .transformed { -webkit-transform: rotateY(50deg); background-color: blue; } .child { -webkit-transform-origin: top left; -webkit-transform: rotateX(40deg); background-color: lime; } <div class="container"> <div class="transformed"> <div class="child"></div> </div> </div>
  • 18. • The lime element is being rendered into the plane of its parent because it is not a member of a 3D rendering context; the parent is "flattening"
  • 19. .container { -webkit-perspective: 500px; border: 1px solid black; } .transformed { -webkit-transform-style: preserve-3d; -webkit-transform: rotateY(50deg); background-color: blue; } .child { -webkit-transform-origin: top left; -webkit-transform: rotateX(40deg); background-color: lime; } <div class="container"> <div class="transformed"> <div class="child"></div> </div> </div>
  • 20. .container { -webkit-perspective: 500px; border: 1px solid black; } .transformed { -webkit-transform-style: preserve-3d; -webkit-transform: rotateY(50deg); background-color: blue; } .child { -webkit-transform-origin: top left; -webkit-transform: rotateX(40deg); background-color: lime; } <div class="container"> <div class="transformed"> <div class="child"></div> </div> </div>
  • 21. • The blue element now establishes a 3D rendering context, of which the lime element is a member. Now both blue and lime elements share a common three-dimensional space, so the lime element renders as tilting out from its parent, influenced by the perspective on the container.
  • 22. .container { background-color: rgba(0, 0, 0, 0.3); transform-style: preserve-3d; perspective: 500px; In safari } .container > div { position: absolute; left: 0; } .container > :first-child { transform: rotateY(45deg); background-color: orange; top: 10px; height: 135px; } In chrome .container > :last-child { transform: translateZ(40px); background-color: rgba(0, 0, 255, 0.75); top: 50px; height: 100px; }
  • 23. Properties, Functions • ‘transform’ property – This property contains a list of transform functions. • ‘transform-origin’ property – This property must be used together with the ‘transform’ property. – http://www.w3schools.com/cssref/css3_pr_transf orm-origin.asp
  • 24. • ‘transform-style’ property – flat|preserve-3d • ‘perspective’ property – http://www.w3schools.com/cssref/trycss3_perspective_inuse.htm • ‘perspective-origin’ property – The resolved value of ‘perspective-origin’ is the used value (i.e., percentages are resolved to absolute lengths). – https://developer.mozilla.org/en/CSS/perspective-origin (firefox) • ‘backface-visibility’ property – Determines whether or not the "back" side of a transformed element is visible when facing the viewer. – visible | hidden
  • 25. • transform function – matrix, matrix3d – translate|X|Y|Z|3d – scale|X|Y|Z|3d – rotate|X|Y|Z|3d – skew|X|Y – perspective
  • 26. And many other things in transforms • SVG transform • Matrix Decomposition for Animation • Unmatrix • Recomposing the matrix • Mathematical Description of Transform Functions
  • 27. Transition Contents • CSS3 Transitions – Transitions – Properties and Funtions – Events
  • 28. Transitions • Animate smoothly from the old state to the new state over time. • Must specify two things – Specify the CSS property you want to add an effect to – Specify the duration of the effect
  • 29. Properties and Functions • Properties – transition ( shorthand property) – transition-property (Specifies the name of the CSS property to which the transition is applied) – transition-duration (Defines the length of time that a transition takes. Default 0) – transition-timing-function (Describes how the speed during a transition will be calculated. Default "ease”) – transition-delay (Defines when the transition will start. Default 0)
  • 30. • ‘transition-timing-function’ details – stepping function • A stepping function is defined by a number that divides the domain of operation into equally sized intervals – cubic Bézier curve • http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_ curves • Functions – ease = cubic-bezier(0.25, 0.1, 0.25, 1.0). – linear = cubic-bezier(0.0, 0.0, 1.0, 1.0). – ease-in = cubic-bezier(0.42, 0, 1.0, 1.0). – ease-out = cubic-bezier(0, 0, 0.58, 1.0). – ease-in-out = cubic-bezier(0.42, 0, 0.58, 1.0) – cubic-bezier(n, n, n, n)
  • 31. • Functions – linear = the same speed from start to end – ease = a slow start, then fast, then end slowly – ease-in = a slow start. – ease-out = a slow end. – ease-in-out = a slow start and end
  • 32. Transition Events • transitionend – Event occurs at the completion of the transition
  • 33. Animations Contents • CSS3 Animations – Animations – Keyframes – Properties – Events
  • 34. Animations • Animations are similar to transitions in that they change the presentational value of CSS properties over time. • The principal difference is that while transitions trigger implicitly when property values change, animations are explicitly executed when the animation properties are applied. ( Because animation require a name of keyframe.)
  • 35. keyframes • Keyframes are used to specify the values for the animating properties at various points during the animation. • The keyframes specify the behavior of one cycle of the animation. • Use a ‘CSS at-rule’, @keyframes
  • 36. • Timing functions for keyframes @keyframes bounce { from { top: 100px; animation-timing-function: ease-out; } 50% { top: 100px; animation-timing-function: ease-in; } to { top: 100px; } }
  • 37. Properties • animation : A shorthand property, except the animation-play-state property • animation-name : name of the @keyframes animation • animation-duration • animation-timing-function : See transition functions • animation-delay • animation-iteration-count : The number of times an animation is played. • animation-direction : Specifies whether or not the animation should play in reverse on alternate cycles. • animation-play-state : Whether the animation is running or paused. • http://www.w3schools.com/css3/css3_animations.asp
  • 41. • Draw a bar. .loading.bar div{ width: 10px; height: 30px; background: black; position: absolute; top: 35px; left: 45px; opacity:0.05; -webkit-animation: fadeit 1.1s linear infinite; }
  • 42. • positioning. .loading.bar div:nth-child(1){ -webkit-transform: rotate(0deg) translate(0, -30px); -webkit-animation-delay:0.39s; } … .loading.bar div:nth-child(8){ -webkit-transform: rotate(315deg) translate(0, -30px); -webkit-animation-delay:1.3s; }
  • 43. • iteration. @-webkit-keyframes fadeit{ 0%{ opacity:1; } 100%{ opacity:0; } }
  • 46. • When the computed value of an animatable property changes, implementations must decide what transitions to start
  • 47. • ul – perspective: 600px; – perspective-origin: 0% 50%; • li – transition: all 600ms ease, opacity 200ms ease; – transform-origin: 0% 0%; • .future or .past – transform: rotateY(90deg); – opacity : 0;
  • 48. • Real sample – http://lab.hakim.se/scroll-effects/ • Conceptual implementation – http://jsfiddle.net/freestrings/hdbUv/

Editor's Notes

  • #6: http://jsfiddle.net/freestrings/ywTvc/
  • #7: http://jsfiddle.net/freestrings/ywTvc/
  • #8: http://jsfiddle.net/freestrings/4A6KD/
  • #9: http://jsfiddle.net/freestrings/4A6KD/
  • #10: Respect : 침해하지 않는.
  • #11: http://jsfiddle.net/freestrings/grwC5/
  • #14: &lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt; &lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;div { height: 150px; width: 150px;}.container { -webkit-perspective: 500px; border: 1px solid black;}.transformed { background-color: blue; -webkit-transform: rotateY(50deg);} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;transformed&quot;&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt;&lt;/html&gt;
  • #15: &lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt; &lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;div { height: 150px; width: 150px;}.container { -webkit-perspective: 500px; border: 1px solid black;}.transformed { background-color: blue; -webkit-transform: rotateY(50deg);} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;transformed&quot;&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt;&lt;/html&gt;
  • #16: &lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt; &lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;div { height: 150px; width: 150px;}.container { -webkit-perspective: 500px; border: 1px solid black;}.transformed { background-color: blue; -webkit-transform: rotateY(50deg);} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;transformed&quot;&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt;&lt;/html&gt;
  • #17: &lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt; &lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;div { height: 150px; width: 150px;}.container { -webkit-perspective: 500px; border: 1px solid black;}.transformed { background-color: blue; -webkit-transform: rotateY(50deg);} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;transformed&quot;&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt;&lt;/html&gt;
  • #18: &lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt; &lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;div { height: 150px; width: 150px;}.container { -webkit-perspective: 500px;border: 1px solid black;}.transformed { -webkit-transform: rotateY(50deg); background-color: blue;}.child { -webkit-transform-origin: top left; -webkit-transform: rotateX(40deg); background-color: lime;} &lt;/style&gt; &lt;/head&gt; &lt;body style=&apos;padding: 200px;&apos;&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;transformed&quot;&gt; &lt;div class=&quot;child&quot;&gt;&lt;/div&gt; &lt;/div&gt;&lt;/div&gt; &lt;/body&gt;&lt;/html&gt;
  • #20: &lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt; &lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;div { height: 150px; width: 150px;}.container { -webkit-perspective: 500px; border: 1px solid black;}.transformed { -webkit-transform-style: preserve-3d; -webkit-transform: rotateY(50deg); background-color: blue;}.child { -webkit-transform-origin: top left; -webkit-transform: rotateX(40deg); background-color: lime;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;transformed&quot;&gt; &lt;div class=&quot;child&quot;&gt;&lt;/div&gt; &lt;/div&gt;&lt;/div&gt; &lt;/body&gt;&lt;/html&gt;
  • #21: &lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt; &lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;div { height: 150px; width: 150px;}.container { -webkit-perspective: 500px; border: 1px solid black;}.transformed { -webkit-transform-style: preserve-3d; -webkit-transform: rotateY(50deg); background-color: blue;}.child { -webkit-transform-origin: top left; -webkit-transform: rotateX(40deg); background-color: lime;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;transformed&quot;&gt; &lt;div class=&quot;child&quot;&gt;&lt;/div&gt; &lt;/div&gt;&lt;/div&gt; &lt;/body&gt;&lt;/html&gt;
  • #23: &lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt; &lt;head&gt; &lt;style type=&quot;text/css&quot;&gt;div { height: 150px; width: 150px;}.container { background-color: rgba(0, 0, 0, 0.3); -webkit-transform-style: preserve-3d; -webkit-perspective: 500px;}.container &gt; div { position: absolute; left: 0;} .container &gt; :first-child { -webkit-transform: rotateY(45deg); background-color: orange; top: 10px; height: 135px;}.container &gt; :last-child { -webkit-transform: translateZ(40px); background-color: rgba(0, 0, 255, 0.75); top: 50px; height: 100px;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt;&lt;/html&gt;
  • #37: animation-name: myfirst;animation-duration: 5s;animation-timing-function: linear;animation-delay: 2s;animation-iteration-count: infinite;animation-direction: alternate;animation-play-state: running;
  • #44: http://jsfiddle.net/freestrings/mLu22/http://blog.crazyegg.com/2012/05/08/loading-spinners-css3-animation/&lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt;&lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;.loading{ width:100px; height:100px; margin:30px auto;position:relative;}.loading.bardiv{ width: 10px; height: 30px; background: black; position: absolute; top: 35px;left: 45px; opacity:0.05; -webkit-animation: fadeit 1.1s linear infinite; -moz-animation: fadeit 1.1s linear infinite; animation: fadeit 1.1s linear infinite;}.loading.bardiv:nth-child(1){ -webkit-transform: rotate(0deg) translate(0, -30px); -moz-transform: rotate(0deg) translate(0, -30px); transform: rotate(0deg) translate(0, -30px); -webkit-animation-delay:0.39s; -moz-animation-delay:0.39s; animation-delay:0.39s;} .loading.bardiv:nth-child(2){ -webkit-transform: rotate(45deg) translate(0, -30px); -moz-transform: rotate(45deg) translate(0, -30px); transform: rotate(45deg) translate(0, -30px); -webkit-animation-delay:0.52s; -moz-animation-delay:0.52s; animation-delay:0.52s;} .loading.bardiv:nth-child(3){ -webkit-transform: rotate(90deg) translate(0, -30px); -moz-transform: rotate(90deg) translate(0, -30px); transform: rotate(90deg) translate(0, -30px); -webkit-animation-delay:0.65s; -moz-animation-delay:0.65s; animation-delay:0.65s;} .loading.bardiv:nth-child(4){ -webkit-transform: rotate(135deg) translate(0, -30px); -moz-transform: rotate(135deg) translate(0, -30px); transform: rotate(135deg) translate(0, -30px); -webkit-animation-delay:0.78s; -moz-animation-delay:0.78s; animation-delay:0.78s;} .loading.bardiv:nth-child(5){ -webkit-transform: rotate(180deg) translate(0, -30px); -moz-transform: rotate(180deg) translate(0, -30px); transform: rotate(180deg) translate(0, -30px); -webkit-animation-delay:0.91s; -moz-animation-delay:0.91s; animation-delay:0.91s;} .loading.bardiv:nth-child(6){ -webkit-transform: rotate(225deg) translate(0, -30px); -moz-transform: rotate(225deg) translate(0, -30px); transform: rotate(225deg) translate(0, -30px); -webkit-animation-delay:1.04s; -moz-animation-delay:1.04s; animation-delay:1.04s;} .loading.bardiv:nth-child(7){ -webkit-transform: rotate(270deg) translate(0, -30px); -moz-transform: rotate(270deg) translate(0, -30px); transform: rotate(270deg) translate(0, -30px); -webkit-animation-delay:1.17s; -moz-animation-delay:1.17s; animation-delay:1.17s;} .loading.bardiv:nth-child(8){ -webkit-transform: rotate(315deg) translate(0, -30px); -moz-transform: rotate(315deg) translate(0, -30px); transform: rotate(315deg) translate(0, -30px); -webkit-animation-delay:1.3s; -moz-animation-delay:1.3s; animation-delay:1.3s;}@-webkit-keyframesfadeit{ 0%{ opacity:1; } 100%{opacity:0; }}@-moz-keyframesfadeit{ 0%{ opacity:1; } 100%{opacity:0; }}@keyframesfadeit{ 0%{ opacity:1; } 100%{opacity:0; }}&lt;/style&gt;&lt;/head&gt;&lt;body style=&apos;padding: 200px&apos;&gt; &lt;div class=&quot;loading bar&quot;&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;
  • #45: http://jsfiddle.net/freestrings/mLu22/http://blog.crazyegg.com/2012/05/08/loading-spinners-css3-animation/&lt;!DOCTYPE html PUBLIC &apos;-//W3C//DTD HTML 4.0//EN&apos;&gt;&lt;html&gt;&lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;.loading{ width:100px; height:100px; margin:30px auto;position:relative;}.loading.bardiv{ width: 10px; height: 30px; background: black; position: absolute; top: 35px;left: 45px; opacity:0.05; -webkit-animation: fadeit 1.1s linear infinite; -moz-animation: fadeit 1.1s linear infinite; animation: fadeit 1.1s linear infinite;}.loading.bardiv:nth-child(1){ -webkit-transform: rotate(0deg) translate(0, -30px); -moz-transform: rotate(0deg) translate(0, -30px); transform: rotate(0deg) translate(0, -30px); -webkit-animation-delay:0.39s; -moz-animation-delay:0.39s; animation-delay:0.39s;} .loading.bardiv:nth-child(2){ -webkit-transform: rotate(45deg) translate(0, -30px); -moz-transform: rotate(45deg) translate(0, -30px); transform: rotate(45deg) translate(0, -30px); -webkit-animation-delay:0.52s; -moz-animation-delay:0.52s; animation-delay:0.52s;} .loading.bardiv:nth-child(3){ -webkit-transform: rotate(90deg) translate(0, -30px); -moz-transform: rotate(90deg) translate(0, -30px); transform: rotate(90deg) translate(0, -30px); -webkit-animation-delay:0.65s; -moz-animation-delay:0.65s; animation-delay:0.65s;} .loading.bardiv:nth-child(4){ -webkit-transform: rotate(135deg) translate(0, -30px); -moz-transform: rotate(135deg) translate(0, -30px); transform: rotate(135deg) translate(0, -30px); -webkit-animation-delay:0.78s; -moz-animation-delay:0.78s; animation-delay:0.78s;} .loading.bardiv:nth-child(5){ -webkit-transform: rotate(180deg) translate(0, -30px); -moz-transform: rotate(180deg) translate(0, -30px); transform: rotate(180deg) translate(0, -30px); -webkit-animation-delay:0.91s; -moz-animation-delay:0.91s; animation-delay:0.91s;} .loading.bardiv:nth-child(6){ -webkit-transform: rotate(225deg) translate(0, -30px); -moz-transform: rotate(225deg) translate(0, -30px); transform: rotate(225deg) translate(0, -30px); -webkit-animation-delay:1.04s; -moz-animation-delay:1.04s; animation-delay:1.04s;} .loading.bardiv:nth-child(7){ -webkit-transform: rotate(270deg) translate(0, -30px); -moz-transform: rotate(270deg) translate(0, -30px); transform: rotate(270deg) translate(0, -30px); -webkit-animation-delay:1.17s; -moz-animation-delay:1.17s; animation-delay:1.17s;} .loading.bardiv:nth-child(8){ -webkit-transform: rotate(315deg) translate(0, -30px); -moz-transform: rotate(315deg) translate(0, -30px); transform: rotate(315deg) translate(0, -30px); -webkit-animation-delay:1.3s; -moz-animation-delay:1.3s; animation-delay:1.3s;}@-webkit-keyframesfadeit{ 0%{ opacity:1; } 100%{opacity:0; }}@-moz-keyframesfadeit{ 0%{ opacity:1; } 100%{opacity:0; }}@keyframesfadeit{ 0%{ opacity:1; } 100%{opacity:0; }}&lt;/style&gt;&lt;/head&gt;&lt;body style=&apos;padding: 200px&apos;&gt; &lt;div class=&quot;loading bar&quot;&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;
  • #46: http://lab.hakim.se/scroll-effects/