Graphics Reference
In-Depth Information
7. Time calculation • As you can see, we create a time object with the cur-
rent time using new Date() . We use getHours() , getMinutes() and
getSeconds() to get the values we want and translate these into pixels
that fit our bar width. To assign the new width to the bar, first obtain a refer-
ence to it. To do this, we use the $ symbol provided by the jQuery function.
As selector, pass it the name of the element as a string. Now that we have
this reference, use the width value of the css() method to set the width of
the element. Repeat this for all three bars, and violà: the clock is ready.
In this example, you learned how to execute actions in a user-defined interval
without playback on the Timeline. Other possible useful scenarios for intervals
Get current tweets from Twitter
Monitor user activity (e.g., mouse movement)
Check if the window is in the browser's focus
Of course, you can stop such an interval again at any time. For this, use the
clearInterval (intervalId) method as follows:
// Start interval
var refreshIntervalId = setInterval( fname, 10000 );
// Stop interval
clearInterval( refreshIntervalId );
Search WWH ::

Custom Search