HACKINTOSH.ORG | Macintosh discussion forums

Macintosh News => iPhone/iPod/iPad News => Topic started by: HCK on October 29, 2014, 03:00:33 am



Title: Understanding CSS Transitions
Post by: HCK on October 29, 2014, 03:00:33 am
Understanding CSS Transitions

<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p><a href='http://www.imore.com/understanding-css-transitions' title="Understanding CSS Transitions"><img src='http://www.imore.com/sites/imore.com/files/styles/large_wm_blw/public/field/image/2014/10/css_animations_transitions_hero.jpg?itok=mpFSDku4' />[/url]</p> <p>The following is excerpted from CSS Animation: An Interactive Guide (http://cssanimationbook.com) by Vicki Murley (http://twitter.com/vickimurley).</p> <p>When the value of a CSS property changes, a web browser immediately renders the result of that change. For example, if you use JavaScript to change the value of the opacity property on an element from 1 to 0, the element immediately disappears. CSS Transitions allow changes in CSS property values to occur smoothly over a period of time, thus creating an animated effect. <!--break-->You can use CSS Transitions to:</p> <ul><li>slide an element across the screen</li> <li>make an element fade in or out </li> <li>interpolate between two colors </li> <li>spin or scale an element </li> </ul><p>...and much more. Most CSS properties can be animated — even 3D transforms — so there's a tremendous number of combinations possible to create unique effects.</p> <p>Code-wise, there are two components needed to define and execute a CSS Transition:</p> <ol><li>A definition for the transition (which includes things like how long it will take), written in CSS.</li> <li>A computed style change to trigger the transition to begin. For example, using JavaScript to change the value of the CSS property being animated.</li> </ol><p>Once you've defined your transition in CSS (part 1 above), the web browser will take care of rendering all the frames of the transition animation when a computed style change occurs (part 2). Besides specifying how long the transition will take, you can also define what sort of timing function will be used (ease, linear, etc.). It's also possible to transition several CSS properties at once.</p> <p>Before digging into all the details of CSS Transitions in later sections of this chapter, let's go over the basics with a simple example. Let's say that you want to make an element disappear when it's clicked, and to do that you're going to change the element's opacity. Listen for an event on the element ( such as click, mousedown, or mouseup), and change the value of the opacity property from 1 to 0 when the event is emitted:</p> <p><a href='http://www.imore.com/understanding-css-transitions' title="Understanding CSS Transitions"><img src='http://www.imore.com/sites/imore.com/files/styles/large/public/field/image/2014/10/PastedGraphic-13.jpeg?itok=DU-w5HsU' />[/url]</p> <p>With this code in place, the element will disappear immediately when clicked. To cause the element to fade out slowly over time, use CSS to define a CSS transition.</p> <p><a href='http://www.imore.com/understanding-css-transitions' title="Understanding CSS Transitions"><img src='http://www.imore.com/sites/imore.com/files/styles/large/public/field/image/2014/10/PastedGraphic-15.jpg?itok=0FPS8TSY' />[/url]</p> <p>For example, if you want the box to fade out uniformly over a period of 3 seconds, add this CSS:</p> <p><a href='http://www.imore.com/understanding-css-transitions' title="Understanding CSS Transitions"><img src='http://www.imore.com/sites/imore.com/files/styles/large/public/field/image/2014/10/PastedGraphic-14.jpeg?itok=PgEcEP70' />[/url]</p> <p>This code sample introduces three CSS properties for defining CSS transitions: transition-property, transition-duration, and transition-timing-function. You'll learn all the details for these properties in the next section called Defining Transitions, and in later sections of this book you'll learn how to:</p> <ul><li>transition multiple CSS properties at once</li> <li>trigger transitions to begin in different ways</li> <li>reverse a transition</li> <li>define your own timing functions</li> <li>chain transitions together</li> </ul><p>For more, get your copy of CSS Animation: An Interactive Guide (http://cssanimationbook.com) by Vicki Murley (http://twitter.com/vickimurley) on iPad or Mac today!</p> <ul><li>$7.99 - <a href="https://itunes.apple.com/ca/book/css-animation-interactive/id799975886?mt=11&amp;at=10l3Vy&amp;ct=d_im" title="" rel="nofollow">Download now[/url]</li> </ul></div></div></div><div id="comment-wrapper-nid-27920"></div><img width='1' height='1' src='http://tipb.com.feedsportal.com/c/33998/f/616881/s/3feb6a5e/sc/4/mf.gif' border='0'/><br clear='all'/>

<a href="http://da.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/rc/1/rc.htm" rel="nofollow"><img src="http://da.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/rc/1/rc.img" border="0"/>[/url]
<a href="http://da.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/rc/2/rc.htm" rel="nofollow"><img src="http://da.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/rc/2/rc.img" border="0"/>[/url]
<a href="http://da.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/rc/3/rc.htm" rel="nofollow"><img src="http://da.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/rc/3/rc.img" border="0"/>[/url]

<img src="http://da.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/a2.img" border="0"/> (http://da.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/a2.htm)<img width="1" height="1" src="http://pi.feedsportal.com/r/211596948829/u/49/f/616881/c/33998/s/3feb6a5e/sc/4/a2t.img" border="0"/><img src="http://feeds.feedburner.com/~r/TheIphoneBlog/~4/E0g3Zrl6FhQ" height="1" width="1"/>

Source: Understanding CSS Transitions (http://feedproxy.google.com/~r/TheIphoneBlog/~3/E0g3Zrl6FhQ/story01.htm)